HTML and CSS Reference
In-Depth Information
13
Streaming Data with Ajax
and Comet
I n Chapter 12, Abstracting Browser Differences: Ajax, we saw how the XML-
HttpRequest object enables web pages to take the role of interactive applications
that can both update data on the back-end server by issuing POST requests, as well
as incrementally update the page without reloading it using GET requests.
In this chapter we will take a look at technologies used to implement live
data streaming between the server and client. This concept was first enabled by
Netscape's Server Push in 1995, and is possible to implement in a variety of ways
in today's browsers under umbrella terms such as Comet , Reverse Ajax, and Ajax
Push. We will look into two implementations in this chapter; regular polling and
so-called long polling.
This chapter will add some features to the tddjs.ajax.request interface
developed in the previous chapter, add a new interface, and finally integrate with
tddjs.util.observable , developed in Chapter 11, The Observer Pattern,
enabling us to create a streaming data client that allows JavaScript objects to observe
server-side events.
The goal of this exercise is twofold: learning more about models for client-
server interaction, and of course test-driven development. Important TDD lessons
in this chapter includes delving deeper into testing asynchronous interfaces and
testing timers. We will continue our discussion of stubbing, and get a glimpse of the
workflow and choices presented to us as we develop more than a single interface.
293
 
 
Search WWH ::




Custom Search