|
|||||||||
| 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 AtmosphereEvent per user. AtmosphereEvent 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(String name,
String followee)
Add a follower, using the user's associated Broadcaster |
Broadcastable |
onLogin(String name,
HttpServletRequest request)
Store the user information and broadcast a welcome message using the already suspended connection done onStart(javax.servlet.http.HttpServletRequest, java.lang.String) |
Broadcastable |
onPush(String message,
String callback,
HttpServletRequest request)
Push tweet to the user and its followers. |
String |
onStart(HttpServletRequest request,
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 |
|---|
public String onStart(@Context
HttpServletRequest request,
String callback)
Suspend scope
to REQUEST, which means every suspended connection by default have their
own instance of Broadcaster
public Broadcastable onLogin(String name,
@Context
HttpServletRequest request)
onStart(javax.servlet.http.HttpServletRequest, java.lang.String)
public Broadcastable onFollow(String name,
String followee)
Broadcaster
name - followee -
public Broadcastable onPush(String message,
String callback,
@Context
HttpServletRequest request)
message - callback - request -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||