So Recently I've been delving into the marvelous world of Pushing data to web browsers.
Ok, before I get flamed, what I mean by pushing (for now) is the browser requesting data and the server sending new events periodically as they happen. Other technologies in this area are things like Comet and Orbited. Many people are already using various methods to implement this, services such as Mibbit, GMail/GDocs, Facebook, Highrise and others.
While this isn't a discussion about why I didn't use the existing approaches, I will say some of them are because the servers are based on Java or Twisted (python), which is bulky and I felt it could be simplified.
For now the general thought process is that the clients web browser requests data from the server via AJAX or JSONP, Flash or an IFrame, and when the server has some data to send, it plops it out, the web browser reads it and everyone is happy...
Limitations of these methods...
Ajax - This is the method Highrise currently uses, they keep polling the server for data.
- Really Simple
- Not real time
- Lots of requests to server
IFrame - You embed an iframe into a web page, you can then fire off requests to the parent frame as soon as they arrive, great!
- It works
- Must use same(ish) domain and port.
- Limited concurrent browser connections, again can be overcome by using subdomains
JSONP - You use script tags to call a script on ANY domain, AWESOME!
- Fabulous, cross domain, the script can return a function call with the new data
- You have to close the connection for each message from the server, meaning you could miss messages whilst reconnecting
- It actually works in most situations (GMail uses it for chat)
- Requires 3rd party application
- Wont work on mobile devices or browsers that don't have support for Flash
I believe in the spec for HTML 5 there is the ability to have this kind of activity built in to browsers so all this data will soon (whenever "soon" is, we'll deal with that when it arrives) become obsolete.
As a conclusion, I wish I had one, but I don't know what to do! I've wrote my own simple socket / web server using Python and it works great, but the browser side is the real issue i'm having, comments and suggestions would be great!