mardi 22 mars 2011

Warning
This is really a draft. It is just working but I'm sure there is better way to do that. Need approving from more experimented atmosphere developers.

The idea behind pushing to individual user is to assign a broadcaster with an id (you get the id from the request parameter for example) to atmosphere resource representing a user (browser). The broadcaster need to be added to the broadcaster factory. Now, at anytime you can get this broadcaster by issuing a lookup by id.

In the previous post we have seen how to setup atmosphere-gwt-demo project under Eclipse. When your run the atmosphere-gwt-demo project you get a window that shows 6 buttons: post request, poll, broadcast, open child window, send to the child window and a stop comet button.

In this post, I'll describes steps I followed to find my way to push to individual users.

The scenario is simple:

An external server send notifications as http post request with one parameter that identifies the target user, the atmosphereHandler receives the notification and send a message to the appropriate browser (The one that has login with the same id)

Right click on atmosphere-gwt-demo->Run As->Maven build ...
In the following dialog, enter "gwt:debug" as goals, save it.

Click on the dropdown of the debug button on the toolbar, select "Debug Configurations".

In the left panel, find “Remote Java Application”, select it and click the icon for "New launch configuration" (top left corner). Accept defaults, save, and close.

Now, you are ready, start the debug server by running the debug launcher we just created. (the one with goal gwt:debug). When you see "Listening for transport dt_socket at address: 8001" in the console output, run the attach launcher we just created (the remote debugger).