Cover image for Building the Realtime User Experience

Book description

The Web is increasingly happening in realtime. With sites such as Facebook and FriendFeed leading the way, users are coming to expect that all websites should serve content to them as it occurs. With this book, you'll learn how to add several realtime features to your site -- everything from chat and messaging services to streaming content feeds -- without making significant changes to your existing infrastructure.

Table of Contents

  1. Special Upgrade Offer
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
    5. Acknowledgments
  4. 1. Introduction
    1. What Is Realtime?
      1. Changing Interactions
    2. Push Versus Pull
    3. Prerequisites
      1. Python
      2. JavaScript
      3. JavaScript Object Notation
      4. Google’s App Engine
    4. The Rest
  5. 2. Realtime Syndication
    1. Simple Update Protocol (SUP)
      1. The SUP file
      2. Subscribing with SUP
        1. Locating SUP feeds
        2. Checking the SUP feed
      3. Publishing with SUP
        1. Generating a SUP file
        2. Testing our SUP file
        3. The SUP header
    2. PubSubHubbub
      1. The Protocol
        1. Subscribe
        2. Publishing content
      2. Subscribing with PubSubHubbub
      3. Publishing with PubSubHubbub
  6. 3. The Dynamic Homepage (Widgets in Pseudorealtime)
    1. The Basic Widgets
      1. HTML
      2. Setting Up the JavaScript
        1. Initialize
        2. A word about JSONP
        3. Catching the trends
        4. Catching the tweets
        5. Displaying the updates
    2. FriendFeed in Realtime
    3. Live Images
    4. It Was All a Setup!
      1. The Old Versus the New
  7. 4. River of Content
    1. A Crash Course in Server Push
      1. Long Polling
      2. The Bayeux Protocol
      3. Cometd
    2. Setting Up Your Cometd Environment
      1. Putting Everything in Its Place
    3. A Realtime Live Blog
      1. The Two-Connection Limit
    4. Server-Side Filters (with Java)
    5. Integrating Cometd into Your Infrastructure
  8. 5. Taming the Firehose with Tornado
    1. Tornado
      1. Installing Tornado
      2. The Basic Framework
      3. Building an Application
      4. Asynchronous Tornado in Realtime
    2. Twitter’s Realtime Streaming APIs
    3. From the Firehose to the Web Browser
      1. Templates in Tornado
      2. Creating a Template for This Project
      3. The JavaScript Parts
  9. 6. Chat
    1. Setting Up the Basic Code
      1. The Basic HTML Frame
      2. The Python Shell
      3. The JavaScript Base
      4. Checking the Progress
    2. Logging In
      1. On the Server Side
      2. JavaScript
    3. Basic Chatting
      1. Chatting on the Server Side
      2. Sending Messages
      3. Receiving Messages
    4. Acting Natural
  10. 7. Instant Messaging
    1. Getting Started with Google App Engine
      1. Setting Up an Account
      2. Creating an Application with the SDK
        1. Inspecting the default application
      3. Taking Advantage of Google
      4. Keeping Track of the User
      5. The Deploy Button
      6. The Dashboard
    2. Receiving Instant Messages
    3. Sending Instant Messages
    4. Responding Intelligently
      1. The Basic Commands
      2. Checking Authentication via Instant Messenger
      3. Introducing a Third Party
    5. Setting Up an API
  11. 8. SMS
    1. The SMS Landscape
      1. Email to SMS
      2. SMS APIs
        1. SMS API providers
    2. Building the Basic Application
      1. Extending the Instant Messaging Application
      2. An SMS Service Class
      3. The Base Handler
      4. Preparing to Accept Messages
      5. Setting Up the Server
    3. Sending and Receiving the Messages
      1. TextMarks
        1. Reserving a keyword
        2. The Python class
        3. Testing it out
      2. Zeep Mobile
        1. Reserving a keyword
        2. The Python class
      3. Authenticating Users
        1. The authentication process
        2. The basic code
          1. Authenticating with Zeep Mobile
          2. Testing the authentication process
      4. Building an SMS API
        1. Testing the API
  12. 9. Measuring User Engagement: Analytics on the Realtime Web
    1. Realtime Analytics Services
      1. Chartbeat
      2. Woopra
    2. Customized Analytics
      1. Sending Tracking Pings with JavaScript
      2. Catching the Statistics on the Server
        1. Testing the pings
      3. Making Sense of the Traffic
      4. Viewing the Traffic
      5. Tracking Backend Traffic and Custom Data
      6. Sending Out Alerts
  13. 10. Putting It All Together
    1. The Game
      1. Caveats
    2. Getting Set Up
      1. Google App Engine
      2. Google Maps API Key
      3. EC2 or Other Hosted Server
      4. GeoModel
    3. The Basic Models
      1. UserInfo
      2. Disease
      3. Germ
      4. CommandCenter
      5. Textmark
      6. Messenger
      7. UserThreats
      8. GameUtils
    4. Building the Game Itself
      1. User Authentication
      2. Geolocation
      3. Spreading Germs
      4. Loading Germs
      5. Threats
        1. Natural threats
        2. Initiating a challenge
        3. Updating threats
        4. Responding to challenge threats: Receiving XMPP and SMS messages
          1. Receiving XMPP messages
          2. Receiving SMS messages
          3. Handling the response
          4. Responses in action
      6. Spreading Germs
      7. Fighting Germs
      8. Realtime Syndication
        1. Publishing the feed
      9. The Command Center
        1. The basic site
        2. Authentication
        3. Consuming PubSubHubbub
        4. Notifying users
          1. Handling long polling on the server
          2. Long polling on the client side
        5. Chat
          1. Server side
          2. Client side
    5. In Review
  14. Index
  15. About the Author
  16. Colophon
  17. Special Upgrade Offer
  18. Copyright