AJAX - The Complete Reference

(avery) #1

516 Part III: Advanced Topics


What to call this push-oriented communication pattern and how exactly it should be
accomplished is subject to much debate and confusion. A continuous polling mechanism
certainly doesn’t count, but if the frequency were enough that it would provide the effective
functionality for most applications—we’ll dub that the fast poll. Another approach would be
to use a long poll, where an XHR is employed and holds a connection open for a long period
of time and then re-establishes the poll every time data is sent or some timeout is reached.
Still another approach is often dubbed the slow load or the “endless iframe,” given how it is
usually implemented as a continuous connection sustained through a connection that never
terminates. We might also introduce true two-way communication using a socket
connection bridged from a Flash file or Java applet into the page—we call that a binary
bridge. Finally, given the need for real-time event handling, some browsers have introduced
native server-event monitoring. All the approaches are summarized in Table 10-2 and shown
visually in Figure 10-9.
We present each of the communication schemes individually to explore their
implementation and network traces before taking a brief look at everyone’s favorite sample
push-style application: chat.

FIGURE 10-8 Comet, push reborn
Free download pdf