forked from Atmosphere/atmosphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating private channel of communication between Browsers
jfarcand edited this page Dec 14, 2012
·
2 revisions
If you want to create a channel of communication between two Browsers (aka user), all you need to do is to create a Broadcaster:
Broadcaster privateChannel = BroadcasterFactory.getDefault().lookup("/private", true);
Next you need to associate the AtmosphereResource, who represent the browser/user to that Broadcaster
privateChannel
.addAtmosphereResource(atmosphereResource_browser1)
.addAtmosphereResource(atmosphereResource_browser2);
You are now ready to broadcast to both browsers/users privately
privateChannel.broadcast("hello");
The hello message will be delivered to both browsers/users.
You can also create Broadcaster for one way communication, e.g from Browser 1 to Browser 2 by doing
Broadcaster toBrowser2 = BroadcasterFactory.getDefault().lookup("/private", true);
toBrowser2.addAtmosphereResource(atmosphereResource_browser2);
toBrowser2.broadcast("Hello from browser 1")
Alternatively, you can use the privateChannel and broadcast to a subset:
privateChannel.broadcast("hello from browser1",atmosphereResource_browser2);
- Understanding Atmosphere
- Understanding Atmosphere's Annotation
- Understanding AtmosphereResource
- Understanding AtmosphereHandler
- Understanding WebSocketHandler
- Understanding Broadcaster
- Understanding BroadcasterCache
- Understanding Meteor
- Understanding BroadcastFilter
- Understanding Atmosphere's Events Listeners
- Understanding AtmosphereInterceptor
- Configuring Atmosphere for Performance
- Understanding JavaScript functions
- Understanding AtmosphereResourceSession
- Using Atmosphere Jersey API
- Using Meteor API
- Using AtmosphereHandler API
- Using Socket.IO
- Using GWT
- Writing HTML5 Server-Sent Events
- Streaming WebSocket messages
- Configuring Atmosphere's Classes Creation and Injection
- Using AtmosphereInterceptor to customize Atmosphere Framework
- Writing WebSocket sub protocol
- Configuring Atmosphere for the Cloud
- Injecting Atmosphere's Components in Jersey
- Sharing connection between Browser's windows and tabs
- Understanding AtmosphereResourceSession
- Server Side: javadoc API
- Server Side: atmosphere.xml and web.xml configuration
- Client Side: atmosphere.js API