zomgistania

Main page | About | Articles | Previous Posts | Archives

Wednesday, September 06, 2006

Server Sent Events: The new chapter in AJAX

Opera 9 features some of the Server-Sent Events features from WHATWG Web Applications 1.0 spec.

But what on earth is that? Well, basically it means that your web page listens to messages from the server! You don't need to do XmlHttpRequests to the server to ask for more data, the server just sends the data to you instead.


A good example of this technology is the Opera Web Chat. Note that it only works in Opera at the moment, as no other browser yet supports SSE.


I created a IRC log forwarder server using Python and Twisted. I first tried using PHP, but I found that it was much easier to have a dedicated server application running and serving clients than trying to keep track of them with PHP, which also seemed to have trouble keeping track of whether the user was disconnected from the page or not. Could've been a problem in my PHP configuration as well, but so what if I can do it easily with Python.


If you are using Opera, you can find the log forwarder from http://iikeli.ath.cx:3080/

to choose a channel use the channel get parameter, ie.
http://iikeli.ath.cx:3080/?channel=lounge for #lounge and
http://iikeli.ath.cx:3080/?channel=opera for #opera

If no channel is selected, it defaults to #opera.

At the moment there are only #opera and #lounge from irc.opera.com available, but I might add more if someone asks me to.

Example HTML page which uses this can be found at http://iikeli.ath.cx:3000/projects/sse/irclog.php
The channel get parameter works with that as well.


I will post the source code for the server script later so hopefully others can learn from it.


For more details on the implementation of SSE in Opera and sample code, visit the Opera Web Applications blog

Labels: , ,

0 Comments:

Post a Comment

<< Home