Friday, September 1st, 2006

Opera 9 Streaming Support

Category: Comet, Opera

<p>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.

Opera’s solution follows the WHAT-WG Server-Sent Event protocol. (How does Cometd relate to SSE? Will there be a fragmentation of standards?)

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.

javascript
< view plain text >
  1. document.getElementsByTagName("event-source")[0]
  2.         .addEventListener("server-time", eventHandler, false);
  3.  
  4. function eventHandler(event)
  5. {
  6.     // Alert time sent by the server
  7.     alert(event.data);
  8. }

To demonstrate the framework, there’s a chat app. (Chat being the Hello World of Comet :-).

Related Content:

Posted by Michael Mahemoff at 8:23 pm
7 Comments

+++--
3.5 rating from 17 votes

7 Comments »

Comments feed TrackBack URI

We need this browser type advancement to improve our apps, this has a lot of potential.

Comment by Peter — September 1, 2006

Yes its great that browser developers add stuff to their browsers. Except its not Opera we need to have adding things and pushing standards, its the folks over in Redmond who need to do this. No matter how many features Firefox or Opera adds it still means that less than 15% of the market share lacks these features.

So this feature is pretty much useless for atleast another few years.

Comment by Philip Plante — September 2, 2006

Ah, but if Opera adds it, Mozilla might consider adding it. And then Redmond might start considering the issue, too. Or we wouldn’t have had IE7 in another 10 years…

Comment by Andrea — September 2, 2006

Actually, what we can do is if Firefox and Opera support something, use the browser’s native abilities and use a shim that you write to that ‘hacks in’ support on IE, similar to what Dojo.Storage does.

Comment by Brad Neuberg — September 3, 2006

Or we could continue to inform the general public of the problems with IE. We are doing more and more of this with my company. Just simply posting on our apps that your browser is not compliant with standards, please download and use FireFox or Opera.

The reaction has been minimal, most people just do it and then tell us that they just continue to use the new browser they installed over IE.

Comment by Michael Benner — September 5, 2006

Cross-document messaging hack

The Dojo and Windows Live Platform teams have both recently released DHTML hacks that allow two iframes in different domains to communicate, bypassing the notorious same-domain policy implemented in browsers. I’m surprised by the relative lack of resp…

Trackback by Curiosity is bliss — September 18, 2006

Weird that the chat example doesn’t work.

Comment by Randomity — December 30, 2006

Leave a comment

You must be logged in to post a comment.