Friday, September 1st, 2006
The Opera webapps blog has a post about Opera 9’s streaming support (via OperaWatch). Whereas “traditional” Ajax apps use some form of polling, there’s clearly a trend towards streaming /Comet. As streaming poses challenges at every point of the HTTP journey (browser, network, server), browser support is clearly welcome as one step towards a robust, scaleable, solution.
To use Server-Sent Events in a web application, add an
element to the document, with a src attribute pointing to a event source URL. This URL should provide a persistent HTTP connection that sends a data stream containing the events. The connection must use the content type application/x-dom-event-stream.
What the server spits out, the browser receives via event handlers.
- .addEventListener("server-time", eventHandler, false);
- function eventHandler(event)
- // Alert time sent by the server
To demonstrate the framework, there’s a chat app. (Chat being the Hello World of Comet :-).
Posted by Michael Mahemoff at 8:23 pm