Event Streaming in Web Browsers

Yeah, I’m going to talk about Opera 9 again, and about “secret” features. Since Opera 9, we’ve had support for “Server-Sent Events”:http://whatwg.org/specs/web-apps/current-work/#scs-server-sent from the Web Applications 1.0 spec. Quoting the entry we just “published”:http://my.opera.com/WebApplications/blog/show.dml/438711 in the Opera “Web Applications blog”:http://my.opera.com/webapplications/
bq. One cool feature we added to Opera 9 is “Server-Sent Events”:http://whatwg.org/specs/web-apps/current-work/#scs-server-sent from the “WHATWG”:http://whatwg.org/ Web Applications 1.0 specification. Using SSE you can push DOM events continously from your web server to the visitor’s browser. This creates a lot of exciting opportunities for web application authors.
As an approach for building Ajax applications wanting near realtime data from the server, this approach is superior: No ugly hacks in the client-side code, just DOM events. After having added an @@ element to your markup, you simply set up an event listener on the element:
==

document.getElementsByTagName("event-source")[0]
.addEventListener("server-time", eventHandler, false);
function eventHandler(event)
{
// Alert time sent by the server
alert(event.data);
}

==
p. Easy, simple and clean. Which is the same on the server. We have built a neat little demo IRC-like “chat client”:http://oxzone.opera.com/webchat/ that is open for testing. The server is built on “Twisted”:http://twistedmatrix.com/, an event-driven networking framework written in Python. During initial testing we tried to put the server through pure, unadulterated load abuse, but were unable to bring it down, which says something about the advantages for this approach on the server as well.
What applications do _you_ see becoming a reality with SSE?

8 Comments

  1. I almost instantly thought about a widget or website that connects to an email hoster and makes use of IMAP features to stay up2date on incoming emails etc. 🙂

  2. What applications? Nothing, until it is supported in Firefox and IE. 😛

  3. Minghong: Just like there are no ActiveX applications out there? Certainly the market for applications based on technology currently only implemented in Opera is small, but if it’s useful it’ll get used.

  4. Asbjørn Ulsberg

     /  2006-09-04

    If the Web Applications 1.0 specifications becomes a W3C recommendation, I would assume that both Firefox and Safari implements it in not a long period of time. Also, considering that Microsoft in many ways has this supported in IE already, one could hope and believe that this is a so-called “low hanging fruit” they will implement in IE 7.5 or so.

  5. Minaro

     /  2006-09-04

    minghong
    You are aware of Opera Platform, right? In the context of applications written to run on top of Opera, it doesn’t matter if other browsers support it or not.
    The important thing is that Opera is moving to standardize it so that others can take advantage of it too, if they wish.

  6. concrats to opera! SSE is quite cool!
    i guess “athena”:http://divmod.org/trac/wiki/DivmodNevow/Athena could profit very much from a widespead SSE implementation.
    it would make the client side implementation of the framework far smaller.
    btw. irc-like demo with nevow/athena:
    “http://d.0xx0.net:6666”:http://d.0xx0.net:6666/
    the demo is far from finished, but multiple rooms are supported and it works in IE and firefox.

  7. asdf

     /  2006-09-19

    why do you close your discussions? it’s incredibly annoying.

  8. asdf: Blame spammers. I don’t have infinite amounts of time available to spend on moderating comments. It’s either the current solution or no commenting function at all.