Changeset 14960 for dojox/trunk/cometd

Show
Ignore:
Timestamp:
08/26/08 16:44:46 (3 months ago)
Author:
kzyp
Message:

Saves are now specific to JsonRestStores? by default. RestChannels? should now work in multiple tabs.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dojox/trunk/cometd/RestChannels.js

    r14901 r14960  
    7979                subscriptions: {}, 
    8080                subCallbacks: {}, 
    81                 autoReconnectTime: 30000, 
     81                autoReconnectTime: 3000, 
    8282                sendAsJson: false, 
    8383                url: '/channels', 
     
    9494                                this.connectionId = dojox._clientId; 
    9595                                var clientIdHeader = this.started ? 'X-Client-Id' : 'X-Create-Client-Id'; 
    96  
     96                                console.log("opening connection"); 
    9797                                var headers = {Accept:this.acceptType}; 
    9898                                headers[clientIdHeader] = this.connectionId; 
     
    101101                                this.lastIndex = 0;  
    102102                                var onerror, onprogress = function(data){ // get all the possible event handlers 
     103                                        console.log("xhr.status", xhr.status); 
    103104                                        if(typeof dojo == 'undefined'){ 
    104105                                                return null;// this can be called after dojo is unloaded, just do nothing in that case 
     
    109110                                        var error = self.onprogress(xhr,data,contentType); 
    110111                                        if(error){ 
    111                                                 onerror(); 
    112                                                 return new Error(error); 
     112                                                if(onerror()){ 
     113                                                        return new Error(error); 
     114                                                } 
    113115                                        } 
    114116                                        if(!xhr || xhr.readyState==4){ 
     
    122124                                }; 
    123125                                onerror = function(error){ 
     126                                        if(xhr && xhr.status == 409){ 
     127                                                // a 409 indicates that there is a multiple connections, and we need to poll 
     128                                                console.log("multiple tabs/windows open, polling"); 
     129                                                self.disconnected(); 
     130                                                return null; 
     131                                        } 
    124132                                        if(self.started){ // this means we need to reconnect 
    125133                                                self.started = false; 
     
    309317                        } 
    310318                        try{ 
    311                                 message.data = message.content || dojo.fromJson(message.responseText); 
     319                                message.data = message.data || dojo.fromJson(message.responseText); 
    312320                        } 
    313321                        catch(e){} 
     
    339347                                } 
    340348                        } 
    341                         else if(dojox.io.httpParse && contentType.match(/application\/http/)){ 
     349                        else if(dojox.io && dojox.io.httpParse && contentType.match(/application\/http/)){ 
    342350                                // do HTTP tunnel parsing 
    343351                                var topHeaders = '';