Kwwika ceased operation on 01/06/2011. Please migrate to Pusher

Exercise 3: More subscribing

Subscribing to more than one topic and user experience (UX) considerations

 

Show multiple tweets

Update your topicUpdated code to prepend new tweets to the latest results element. This should ensure that the latest result is always at the top.

 

Subscribe to multiple topics

It's possible to subscribe to more than one topic at a time. Update your page to subscribe to an additional topic that contains real-time updates for all tweets containing the#spa2010 hashtag.

 

Subscribe to /KWWIKA/TWITTER/HASHTAGS/SPA2010

 

Coping with large amounts of data

Once the web page has received a lot of updates the memory used by the browser will increase. The page will also become visually very large. A good way to work around both of these problems is to remove older tweets.

 

Restrict you webpage to show only 25 tweets at any one time and remove any older tweets.

 

Add detail to your web page

A tweet contains more than just a ScreenName and Text. It also contains information about a user profile image and the time the tweet was sent. Consider adding the following pieces of information to your displayed tweets.

 

  • User profile image
  • Time the tweet was sent
  • A link to the users Twitter page
  • A link to the dedicated tweet page

 

The available fields are:

 

  • Text
  • ScreenName
  • InReplyToScreenName
  • InReplyToStatusId
  • InReplyToUserId
  • UserName
  • Id
  • Source
  • Truncated
  • Favourited
  • UserFollowersCount
  • UserProfileImageUrl

 

Extra

The topics that we are subscribing to don't update all that often. Try subscribing to /KWWIKA/TWITTER/HASHTAGS/NOWPLAYING and consider how you would deal with this within your web application.

 

Hints & Tips

 

// Define a subscription listener object.

     var oSubscriptionListener = function() {

      this.topicUpdated = function(oSub, mUpdate) {

            // handle update

      };

      this.topicError = function(oSubscription, sReason) {

            // handle errors

      }

}

var oSub = oConn.subscribe("/KWWIKA/TWITTER/HASHTAGS/TECH"oSubscriptionListener);

          var oSub2 = oConn.subscribe("/KWWIKA/TWITTER/HASHTAGS/SPA2010"oSubscriptionListener);      

 

The next exercise is Exercise 4: Chat

Sign in  |  Recent Site Activity  |  Terms  |  Report Abuse  |  Print page  |  Powered by Google Sites