You are previewing Comet and Reverse Ajax: The Next-Generation Ajax 2.0.
O'Reilly logo
Comet and Reverse Ajax: The Next-Generation Ajax 2.0

Book Description

One of the most basic laws of a web application is that the client, not the server, must initiate any communication between the two. There are a number of common-use cases where, ideally, the server would like to talk to the client-dashboards and monitoring apps, chat rooms and other collaborations, and progress reports on long-running processes. Comet (a.k.a. Reverse Ajax) provides a mechanism for enabling this. Comet is moderately complex to implement. But this practical, hands-on book gets you going.

  • In Part 1 of this book, we start by examining the use cases, and look at the simple alternatives to Comet and how far they can satisfy your needs. In some situations, though, only Comet will do.

  • In Part 2, we demonstrate how to set up and run a Comet-based application.

With this book, be a part of the next generation, Ajax 2.0.

Table of Contents

  1. Copyright
  2. Comet and Reverse Ajax: The Next-Generation Ajax 2.0
  3. 1. What Are Comet and Reverse Ajax?
    1. 1.1. The Trouble with HTTP
    2. 1.2. Some Common Use Cases
      1. 1.2.1. Monitoring and Data Feeds
      2. 1.2.2. Progress Updates
      3. 1.2.3. Chat and Collaboration
    3. 1.3. Summary
  4. 2. Simple Ways to Achieve Push
    1. 2.1. The Magnetic Poetry Application
      1. 2.1.1. Creating New Words
      2. 2.1.2. Reading Words
      3. 2.1.3. Updating Words
      4. 2.1.4. Deleting Words
    2. 2.2. Introducing Push Using Polling
    3. 2.3. Improving Efficiency Using Piggybacking
    4. 2.4. Summary
  5. 3. Introducing Comet
    1. 3.1. Implementing a Comet Feed Using XHR
    2. 3.2. Script Tags, Iframes, and Comet
    3. 3.3. Long Polling
    4. 3.4. Issues with Naive Comet Implementations
      1. 3.4.1. Request Limits in the Browser
      2. 3.4.2. Server-Side Performance Concerns
      3. 3.4.3. Network Infrastructure
    5. 3.5. Summary
  6. 4. Comet the Easy Way
    1. 4.1. The Emergence of Comet Tools
    2. 4.2. Direct Web Remoting
      1. 4.2.1. DWR in Action
      2. 4.2.2. DWRServlet
    3. 4.3. DWR and Comet
      1. 4.3.1. Magnetic Poetry Meets DWR on the Client Side
      2. 4.3.2. Magnetic Poetry and DWR on the Server Side
      3. 4.3.3. Routing Magnetic Poetry Events
      4. 4.3.4. Wrapping Up This Implementation
    4. 4.4. Summary
  7. 5. Scaling Comet in Java
    1. 5.1. Thread Management for the Web
      1. 5.1.1. wait/notify
      2. 5.1.2. Difficulties in Using wait/notify with Comet
    2. 5.2. Jetty 6
      1. 5.2.1. Using Jetty Continuations
      2. 5.2.2. Understanding the Continuation Mechanism
      3. 5.2.3. Drawbacks of Continuations
    3. 5.3. Jetty Continuations and DWR
    4. 5.4. Future Comet Support in Java
    5. 5.5. Summary
  8. 6. Introducing Bayeux
    1. 6.1. HTTP Request Management
    2. 6.2. Naming Channels
    3. 6.3. Message Format
    4. 6.4. Standard Channels
    5. 6.5. Transport Negotiation
    6. 6.6. Client-Side Implementations
    7. 6.7. Server-Side Implementations
    8. 6.8. Using Bayeux with Dojo and Jetty
    9. 6.9. Server-Side Messaging
    10. 6.10. Summary
  9. 7. Combining Comet with CRUD
    1. 7.1. Revisiting Magnetic Poetry
    2. 7.2. Client-Side Initialization Code
    3. 7.3. Server-Side Initialization Code
    4. 7.4. Creating Domain Objects
    5. 7.5. Updating Domain Objects
    6. 7.6. Deleting Domain Objects
    7. 7.7. Using Cometd for Progress Reports
    8. 7.8. Additional Resources
      1. 7.8.1. Further Reading
      2. 7.8.2. Further Implementations
      3. 7.8.3. Emerging Standards
    9. 7.9. Summary