org.atmosphere.samples.twitter
Class TwitterResource

java.lang.Object
  extended by org.atmosphere.samples.twitter.TwitterResource

@Singleton
public class TwitterResource
extends Object

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.

Author:
Jeanfrancois Arcand, Paul Sandoz

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

TwitterResource

public TwitterResource()
Method Detail

onStart

public String onStart(@Context
                      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


onLogin

public Broadcastable onLogin(String name,
                             @Context
                             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)


onFollow

public Broadcastable onFollow(String name,
                              String followee)
Add a follower, using the user's associated Broadcaster

Parameters:
name -
followee -
Returns:

onPush

public Broadcastable onPush(String message,
                            String callback,
                            @Context
                            HttpServletRequest request)
Push tweet to the user and its followers.

Parameters:
message -
callback -
request -
Returns:


Copyright © 2009 SUN Microsystems. All Rights Reserved.