users@grizzly.java.net

Re: Problem with comet-based web app -- Streaming

From: Kawajiri Takeshi <taken.kz_at_gmail.com>
Date: Wed, 5 Nov 2008 13:03:09 +0900

Hello.

> I mean did you find this somewhere or basicly invent this technique?

It is not my original :)
I refered these blogs.

http://cometdaily.com/2007/11/18/ie-activexhtmlfile-transport-part-ii/
http://meteorserver.org/browser-techniques/

and It's my understanding that these technique come from google(gtalk).

> I was able to implement actual streaming for IE6 and 7.

Good Job!
ActiveX techique is not special, But I thisk this example is really useful
in terms of dancing with bear.
I hope to add InteractiveXHR(FF) and event-source(Opera) support to
this example :)
Only put if-statement like this.
--
    // 1: InteractiveXHR 2: event-source 3: ActiveX
    this.type = (Prototype.Browser.IE ? 3 : (Prototype.Browser.Opera ? 2 : 1));
    var url = _url + ( _url.search("\\?") > -1 ? "&" : "?") + "type="
+ this.type;
---
and, FYI
(1)check this line
>  writer.write("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body onload=\"parent.callback('reconnect', false)\">");
this onload event is called when browser disconnected.
so, it is better add your client.
----
   var ies = new
IeStream('http://www.test.com:8182/CometStream/',function(event,message){
       if(event == 'reconnect') {
         ies.connect();
       }
       message = Object.toJSON(message).evalJSON();
       ...
   });
---
InteractiveXHR's reconnect is here.
---
      onSuccess: function(stream) {
        this.callback("reconnect", false);
      }.bind(this)
---
Opera?
He try to reconnect automatically.
(2) I forgot to put client's abort method.
but it is very simple.
(a)ActiveX ant Event-Stream(IE&Opera)
 overwrite src attribute to 'about:blank'. don't recreate activeX obj
(b)InteractiveXHR(Safari&CHROME)
 call xhr.abort();
(3) Some browser has max connection per domain.
IE setting is 2.
this mean, If you open 2 tab in same page,
It blooks all other post request.
so, you should resume old request manually per user.
> Would you be interested to blog about it?
I can't, because my english is poor, and I have no time ;)
So, I hope somebody blog it!
Thanks