Changeset 8579
- Timestamp:
- 05/11/07 16:42:01 (19 months ago)
- Files:
-
- 1 modified
-
dojox/trunk/io/cometd.js (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojox/trunk/io/cometd.js
r8548 r8579 73 73 var bindArgs = { 74 74 url: this.url, 75 handleAs: " text/json",75 handleAs: "json", 76 76 content: { "message": dojo.toJson([props]) }, 77 77 jsonpParam: "jsonp" // usually ignored … … 105 105 } 106 106 d.addCallback(dojo.hitch(this, "finishInit")); 107 d.addErrback(function(e){ console.debug("handshake error!:", e); }); 107 108 return d; 108 109 } 109 110 110 this.finishInit = function( type, data, evt, request){111 this.finishInit = function(data){ 111 112 data = data[0]; 112 113 this.handshakeReturn = data; … … 150 151 this._deliver = function(message){ 151 152 // dipatch events along the specified path 152 if(!message["channel"]){153 console.debug("cometd error: no channel for message!");154 return;155 }156 153 if(!this.currentTransport){ 157 154 this.backlog.push(["deliver", message]); 158 155 return; 159 156 } 157 if(!message["channel"]){ 158 if(message["success"] !== true){ 159 console.debug("cometd error: no channel for message!", message); 160 return; 161 } 162 } 160 163 this.lastMessage = message; 161 164 // check to see if we got a /meta channel message that we care about 162 if( (message.channel.length > 5)&& 165 if( (message["channel"]) && 166 (message.channel.length > 5)&& 163 167 (message.channel.substr(0, 5) == "/meta")){ 164 168 // check for various meta topic actions that we need to respond to … … 186 190 // dispatch the message to any locally subscribed listeners 187 191 var tname = (this.globalTopicChannels[message.channel]) ? message.channel : "/cometd"+message.channel; 188 dojo.publish(tname, message);192 dojo.publish(tname, [ message ]); 189 193 } 190 194 } … … 268 272 /*obj*/ message){ 269 273 console.debug(channel); 270 console.debug Shallow(message);274 console.debug(message); 271 275 } 272 276 … … 301 305 // destroy the local topic? 302 306 var tname = (useLocalTopics) ? channel : "/cometd"+channel; 303 dojo. event.topic.unsubscribe(tname, objOrFunc, funcName);307 dojo.unsubscribe(tname, objOrFunc, funcName); 304 308 } 305 309 return this.currentTransport.sendMessage({ … … 311 315 this.unsubscribed = function(/*string*/ channel, 312 316 /*obj*/ message){ 313 console.debug(channel); 314 console.debugShallow(message); 317 console.debug(channel, message); 315 318 } 316 319 … … 455 458 case "/meta/connect": 456 459 if(!message.successful){ 457 dojo.debug("cometd connection error:", message.error);460 console.debug("cometd connection error:", message.error); 458 461 return; 459 462 } … … 464 467 case "/meta/reconnect": 465 468 if(!message.successful){ 466 dojo.debug("cometd reconnection error:", message.error);469 console.debug("cometd reconnection error:", message.error); 467 470 return; 468 471 } … … 471 474 case "/meta/subscribe": 472 475 if(!message.successful){ 473 dojo.debug("cometd subscription error for channel", message.channel, ":", message.error);476 console.debug("cometd subscription error for channel", message.channel, ":", message.error); 474 477 return; 475 478 } 476 479 // this.subscribed(message.channel); 477 dojo.debug(message.channel);480 console.debug(message.channel); 478 481 break; 479 482 } … … 482 485 483 486 this.openTunnelWith = function(content, url){ 484 dojo.xhrPost({ 487 console.debug("openTunnelWith:", content, (url||cometd.url)); 488 var d = dojo.xhrPost({ 485 489 url: (url||cometd.url), 486 490 content: content, 487 handleAs: "text/json", 488 }).addCallback(dojo.hitch(this, function(data){ 489 // console.debug(evt.responseText); 490 cometd.deliver(data); 491 this.connected = false; 492 this.tunnelCollapse(); 493 })).addErrback(function(){ 494 console.debug("tunnel opening failed"); 491 handleAs: "json", 492 }); 493 d.addCallback(dojo.hitch(this, function(data){ 494 // console.debug(evt.responseText); 495 console.debug(data); 496 cometd.deliver(data); 497 this.connected = false; 498 this.tunnelCollapse(); 499 })); 500 d.addErrback(function(err){ 501 console.debug("tunnel opening failed:", err); 495 502 }); 496 503 this.connected = true; … … 545 552 // FIXME: open up the connection here 546 553 this.openTunnelWith({ 547 message: dojo. json.serialize([554 message: dojo.toJson([ 548 555 { 549 556 channel: "/meta/connect", … … 563 570 this.connected = false; 564 571 this.openTunnelWith({ 565 message: dojo. json.serialize([572 message: dojo.toJson([ 566 573 { 567 574 channel: "/meta/reconnect",