Chat application and sending notifications to other users

I wish to build a simple proof of concept chat app. The first hurdle is I can’t figure out how to send notification to other users when someone logs in. Typically “User X has logged in” would be notification sent to other connected users. How this can be done?

If I understand correctly, I will have to use listeners for events approach just like MultiUserCalender demo available at addon example but being new to Java and Vaadin itself I find it little difficult to grasp the concepts. When a new user logs in, it would trigger userLoggedIn event and event listeners from other application instances would catch that and show notifications in their respective windows. Is this right? Which topics I should make myself familiar with, to get this thing done?

Artur has made a chat application with his icepush addon, but I can’t find the sources for that at the moment.

I, however, have done a chat application with my Refresher addon (which is a comparable thing, but it polls instead of pushes), and I’ve written an article about it:
. Feel free to learn and adapt it to your needs.

To your specific requirement, since each user gets their own Application instance, you need to trigger an event whenever a new Application is created (or perhaps, once that Application’s user has chosen his nickname), so that the other users (i.e. Application object instances) can hear it.

Hello Henrik, I had gone through your chat application’s wiki page and found it very interesting indeed. Being a new user to Vaadin as well as Java world, I learned couple of new things.

Chat interface is just a small part of my application which allows multiple users to draw UML like diagrams in real-time collaboratively. I have implemented events and listeners method using Blackboard addon and it wokrs quite nicely with ICEPush addon. I am storing blackboard and associated application instances in a hash map and passing those with the event generated so listeners can push notification to their respective windows.

I was wondering how efficient(performance) it would be to use Refresher addon as compared to ICEPush addon in a scenario where 10 users are collaborating on a diagram at the same time? I can imagine it is kind of vague question but lets assume that every user changes label of specific part of a diagram 5 times in a mintute. Which addon you would choose to update UI - ICEPush or Refresher?


If I were you, I’d probably start out with ICEPush, and if for some reasons some problems occur with it, use Refresher as a backup. The Refresher might be more reliable (doesn’t keep TCP connections to servers open “for nothing”), but pushing is more efficient.

Thanks Henrik for quick replies. I am currently using ICEPush but like you suggested if something doesn’t work as expected(I doubt that) I can always come back to your Refresher addon.

How is pushing more efficient? Probably because UI is updated only when needed but a client-server connection has to be kept alive as a downside. Is that correct? I am curious.

That’s exactly right. Pushing has no unnecessary back-and-forth communcation, but it keeps a TCP connection open with the server at all times, which might slow down site loading, since there’s a limited amount of TCP connections a browser has open per domain simultaneously. Also, if it’s a
high-traffic server, the server might run out of sockets, so no new users can connect.

From what I understand, you would need to be running hundreds, possibly thousands upon thousands of users simultaneously to notice any performance hit from either approach, even on a 10 year old computer.