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<String> onFollow(TwitterBroadcaster userBc, String name, String followee)
          Add a follower, using the user's associated Broadcaster
 Broadcastable<String> 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<String> 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

TwitterResource

public TwitterResource()
Method Detail

onStart

public 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


onLogin

public Broadcastable<String> onLogin(@Context
                                     TwitterBroadcaster bc,
                                     String name)
Store the user information and broadcast a welcome message using the already suspended connection done onStart(java.lang.String)


onFollow

public Broadcastable<String> onFollow(@Context
                                      TwitterBroadcaster userBc,
                                      String name,
                                      String followee)
Add a follower, using the user's associated Broadcaster

Parameters:
name -
followee -
Returns:

onPush

public Broadcastable<String> onPush(@Context
                                    TwitterBroadcaster bc,
                                    String message,
                                    String callback)
Push tweet to the user and its followers.

Parameters:
message -
callback -
request -
Returns:


Copyright © 2009 SUN Microsystems. All Rights Reserved.