views:

486

answers:

3

I would like to know how Gmail (or anyone else) does comet on Opera.

Here is what I know so far from my experiments.

  1. It doesn't use the event-source tag which is broken in Opera 10.51.
  2. It doesn't use iframe which displays a spinning throbber and a busy mouse cursor.
  3. It doesn't use responseText on xmlhttprequest when readyState = 3 which is known to be broken on Opera.

I tried seeing how it was done in mibbit and etherpad, and I found that they both use long-polling.

Bounty

The bounty goes to whoever can tell me a method better than "event-source" for Opera comet streaming, or how gmail does streaming (or long-polling if it does that).

A: 

I really don't have any idea on what the answer is. But I know Opera supports server-events : http://my.opera.com/WebApplications/blog/show.dml/438711 . Maybe it's a step towards the anwser? I'm not really sure either, but I think they use it within Opera Unite.

Savageman
No, it doesn't use event-source like I said. Event-source is completely broken in Opera 10.51, and gmail still streams gchat just fine.
Unknown
+6  A: 

GMail uses BrowserChannel (Docs | Source), which is included in Google's Closure Library.

  • @fileoverview Definition of the BrowserChannel class. A BrowserChannel
  • simulates a bidirectional socket over HTTP. It is the basis of the
  • Gmail Chat IM connections to the server.
Jason Hall
i.e. http://closure-library.googlecode.com/svn/docs/closure_goog_net_browserchannel.js.htmlThink what you're actually looking for is around here:http://closure-library.googlecode.com/svn/docs/closure_goog_net_channelrequest.js.source.htmlsearch for pollResponse_ and getNextChunk_ :)
hallvors
Can you be a little more specific? I feel that I've given a generous enough bounty to warrant an answer more than just a link to a giant abstract library.
Unknown
Well, I sort of feel that should be left to Jason as he gave the original pointer to Closure and I just went a little bit deeper.. Looking at that source code, it seems to use an async XMLHttpRequest indeed, with a timeout that's responsible for polling the responseText and handle incoming data. Opera doesn't fire several readystatechange events while chunked data is coming in (which Firefox does mostly by a happy accident I think - there is no standard or documentation mandating this implementation as far as I know). So instead of expecting multiple readystatechange events they use timeouts.
hallvors
@hallvors, yes I was addressing Jason. If you leave a more detailed answer I will accept yours unless you feel that Jason deserves the bounty.
Unknown
Unfortunately the documentation on BrowserChannel is pretty thin, and I don't have any first-hand experience with it myself, so I can't really say how it solves this particular problem. The best you can do is look at the code and try to work it out. If you don't think I deserve the bounty, I'm fine with that, I was just trying to point you in a helpful direction.
Jason Hall
There's a sidebar question which seems like it may also be helpful? http://stackoverflow.com/questions/2481696/how-does-gmail-implement-comet
Jason Hall
@Jason, I will give you the bounty if your remains the best answer. But if you can improve it some more, I will give you the bounty right away.
Unknown
A: 

I think that rather cross-browser (including Opera) approach might be to stream data through an Adobe Flash application. Though it would introduce dependence on the Flash plugin and is not very popular because of that.

newtover