Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / cometd / callbackPollTransport.js @ 13

History | View | Annotate | Download (2.7 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.cometd.callbackPollTransport"]){
9
dojo._hasResource["dojox.cometd.callbackPollTransport"]=true;
10
dojo.provide("dojox.cometd.callbackPollTransport");
11
dojo.require("dojox.cometd._base");
12
dojo.require("dojox.cometd.longPollTransport");
13
dojo.require("dojo.io.script");
14
dojox.cometd.callbackPollTransport=new function(){
15
this._connectionType="callback-polling";
16
this._cometd=null;
17
this.check=function(_1,_2,_3){
18
return (dojo.indexOf(_1,"callback-polling")>=0);
19
};
20
this.tunnelInit=function(){
21
var _4={channel:"/meta/connect",clientId:this._cometd.clientId,connectionType:this._connectionType,id:""+this._cometd.messageId++};
22
_4=this._cometd._extendOut(_4);
23
this.openTunnelWith([_4]);
24
};
25
this.tunnelCollapse=dojox.cometd.longPollTransport.tunnelCollapse;
26
this._connect=dojox.cometd.longPollTransport._connect;
27
this.deliver=dojox.cometd.longPollTransport.deliver;
28
this.openTunnelWith=function(_5,_6){
29
this._cometd._polling=true;
30
var _7={load:dojo.hitch(this,function(_8){
31
this._cometd._polling=false;
32
this._cometd.deliver(_8);
33
this._cometd._backon();
34
this.tunnelCollapse();
35
}),error:dojo.hitch(this,function(_9){
36
this._cometd._polling=false;
37
this._cometd._publishMeta("connect",false);
38
this._cometd._backoff();
39
this.tunnelCollapse();
40
}),url:(_6||this._cometd.url),content:{message:dojo.toJson(_5)},callbackParamName:"jsonp"};
41
var _a=this._cometd._connectTimeout();
42
if(_a>0){
43
_7.timeout=_a;
44
}
45
dojo.io.script.get(_7);
46
};
47
this.sendMessages=function(_b){
48
for(var i=0;i<_b.length;i++){
49
_b[i].clientId=this._cometd.clientId;
50
_b[i].id=""+this._cometd.messageId++;
51
_b[i]=this._cometd._extendOut(_b[i]);
52
}
53
var _c={url:this._cometd.url||dojo.config["cometdRoot"],load:dojo.hitch(this._cometd,"deliver"),callbackParamName:"jsonp",content:{message:dojo.toJson(_b)},error:dojo.hitch(this,function(_d){
54
this._cometd._publishMeta("publish",false,{messages:_b});
55
}),timeout:this._cometd.expectedNetworkDelay};
56
return dojo.io.script.get(_c);
57
};
58
this.startup=function(_e){
59
if(this._cometd._connected){
60
return;
61
}
62
this.tunnelInit();
63
};
64
this.disconnect=dojox.cometd.longPollTransport.disconnect;
65
this.disconnect=function(){
66
var _f={channel:"/meta/disconnect",clientId:this._cometd.clientId,id:""+this._cometd.messageId++};
67
_f=this._cometd._extendOut(_f);
68
dojo.io.script.get({url:this._cometd.url||dojo.config["cometdRoot"],callbackParamName:"jsonp",content:{message:dojo.toJson([_f])}});
69
};
70
this.cancelConnect=function(){
71
};
72
};
73
dojox.cometd.connectionTypes.register("callback-polling",dojox.cometd.callbackPollTransport.check,dojox.cometd.callbackPollTransport);
74
}