|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.atmosphere.samples.twitter.TwitterResource
@Singleton public class TwitterResource
Twitter like Comet application. This rest based web application implements the logic
needed to support micro blogging a la Twitter.com. Users can blog about what
they are doing and can also follow their friends. When an update is made
by one user, all its follower gets updated automatically. The updated words
can be moved on the screen and all follower will see the move.
This Singleton demonstrate how multiple Broadcaster can be
used to easily isolate suspended connection and to only
push messages to a subset of those suspended connection using the Suspend annotation.
There is one AtmosphereResourceEvent per user. AtmosphereResourceEvent associated
with the user suspended connection are added to their Broadcaster
and added to the Broadcaster of the users they are following.
| Constructor Summary | |
|---|---|
TwitterResource()
|
|
| Method Summary | |
|---|---|
Broadcastable |
onFollow(TwitterBroadcaster userBc,
String name,
String followee)
Add a follower, using the user's associated Broadcaster |
Broadcastable |
onLogin(TwitterBroadcaster bc,
String name)
Store the user information and broadcast a welcome message using the already suspended connection done onStart(java.lang.String) |
Broadcastable |
onPush(TwitterBroadcaster bc,
String message,
String callback)
Push tweet to the user and its followers. |
String |
onStart(String callback)
When the page loads, suspend the response and set the Suspend scope
to REQUEST, which means every suspended connection by default have their
own instance of Broadcaster |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TwitterResource()
| Method Detail |
|---|
@Suspend(scope=REQUEST) public String onStart(String callback)
Suspend scope
to REQUEST, which means every suspended connection by default have their
own instance of Broadcaster
public Broadcastable onLogin(@Context
TwitterBroadcaster bc,
String name)
onStart(java.lang.String)
public Broadcastable onFollow(@Context
TwitterBroadcaster userBc,
String name,
String followee)
Broadcaster
name - followee -
public Broadcastable onPush(@Context
TwitterBroadcaster bc,
String message,
String callback)
message - callback - request -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||