//>>built define(["dijit","dojo","dojox","dojo/require!dojox/xmpp/bosh,dojox/xmpp/util,dojox/data/dom"],function(_1,_2,_3){ _2.provide("dojox.xmpp.TransportSession"); _2.require("dojox.xmpp.bosh"); _2.require("dojox.xmpp.util"); _2.require("dojox.data.dom"); _3.xmpp.TransportSession=function(_4){ this.sendTimeout=(this.wait+20)*1000; if(_4&&_2.isObject(_4)){ _2.mixin(this,_4); if(this.useScriptSrcTransport){ this.transportIframes=[]; } } }; _2.extend(_3.xmpp.TransportSession,{rid:0,hold:1,polling:1000,secure:false,wait:60,lang:"en",submitContentType:"text/xml; charset=utf=8",serviceUrl:"/httpbind",defaultResource:"dojoIm",domain:"imserver.com",sendTimeout:0,useScriptSrcTransport:false,keepAliveTimer:null,state:"NotReady",transmitState:"Idle",protocolPacketQueue:[],outboundQueue:[],outboundRequests:{},inboundQueue:[],deferredRequests:{},matchTypeIdAttribute:{},open:function(){ this.status="notReady"; this.rid=Math.round(Math.random()*1000000000); this.protocolPacketQueue=[]; this.outboundQueue=[]; this.outboundRequests={}; this.inboundQueue=[]; this.deferredRequests={}; this.matchTypeIdAttribute={}; this.keepAliveTimer=setTimeout(_2.hitch(this,"_keepAlive"),10000); if(this.useScriptSrcTransport){ _3.xmpp.bosh.initialize({iframes:this.hold+1,load:_2.hitch(this,function(){ this._sendLogin(); })}); }else{ this._sendLogin(); } },_sendLogin:function(){ var _5=this.rid++; var _6={content:this.submitContentType,hold:this.hold,rid:_5,to:this.domain,secure:this.secure,wait:this.wait,"xml:lang":this.lang,"xmpp:version":"1.0",xmlns:_3.xmpp.xmpp.BODY_NS,"xmlns:xmpp":"urn:xmpp:xbosh"}; var _7=_3.xmpp.util.createElement("body",_6,true); this.addToOutboundQueue(_7,_5); },_sendRestart:function(){ var _8=this.rid++; var _9={rid:_8,sid:this.sid,to:this.domain,"xmpp:restart":"true","xml:lang":this.lang,xmlns:_3.xmpp.xmpp.BODY_NS,"xmlns:xmpp":"urn:xmpp:xbosh"}; var _a=_3.xmpp.util.createElement("body",_9,true); this.addToOutboundQueue(_a,_8); },processScriptSrc:function(_b,_c){ var _d=_3.xml.parser.parse(_b,"text/xml"); if(_d){ this.processDocument(_d,_c); }else{ } },_keepAlive:function(){ if(this.state=="wait"||this.isTerminated()){ return; } this._dispatchPacket(); this.keepAliveTimer=setTimeout(_2.hitch(this,"_keepAlive"),10000); },close:function(_e){ var _f=this.rid++; var req={sid:this.sid,rid:_f,type:"terminate"}; var _10=null; if(_e){ _10=new _3.string.Builder(_3.xmpp.util.createElement("body",req,false)); _10.append(_e); _10.append(""); }else{ _10=new _3.string.Builder(_3.xmpp.util.createElement("body",req,false)); } this.addToOutboundQueue(_10.toString(),_f); this.state=="Terminate"; },dispatchPacket:function(msg,_11,_12,_13){ if(msg){ this.protocolPacketQueue.push(msg); } var def=new _2.Deferred(); if(_11&&_12){ def.protocolMatchType=_11; def.matchId=_12; def.matchProperty=_13||"id"; if(def.matchProperty!="id"){ this.matchTypeIdAttribute[_11]=def.matchProperty; } } this.deferredRequests[def.protocolMatchType+"-"+def.matchId]=def; if(!this.dispatchTimer){ this.dispatchTimer=setTimeout(_2.hitch(this,"_dispatchPacket"),600); } return def; },_dispatchPacket:function(){ clearTimeout(this.dispatchTimer); delete this.dispatchTimer; if(!this.sid){ return; } if(!this.authId){ return; } if(this.transmitState!="error"&&(this.protocolPacketQueue.length==0)&&(this.outboundQueue.length>0)){ return; } if(this.state=="wait"||this.isTerminated()){ return; } var req={sid:this.sid,xmlns:_3.xmpp.xmpp.BODY_NS}; var _14; if(this.protocolPacketQueue.length>0){ req.rid=this.rid++; _14=new _3.string.Builder(_3.xmpp.util.createElement("body",req,false)); _14.append(this.processProtocolPacketQueue()); _14.append(""); delete this.lastPollTime; }else{ if(this.lastPollTime){ var now=new Date().getTime(); if(now-this.lastPollTime0){ var _19=this.inboundQueue.shift(); this.processDocument(_19["doc"],_19["rid"]); } },addToInboundQueue:function(doc,rid){ for(var i=0;i=400&&_20<500){ this.setState("Terminate",_21); return false; }else{ this.removeFromOutboundQueue(rid); setTimeout(_2.hitch(this,function(){ this.dispatchPacket(); }),200); return true; } return false; } if(err&&err.dojoType&&err.dojoType=="timeout"){ } this.removeFromOutboundQueue(rid); if(err&&err.firstChild){ if(err.firstChild.getAttribute("type")=="terminate"){ var _22=err.firstChild.firstChild; var _21=""; if(_22&&_22.nodeName=="conflict"){ _21="conflict"; } this.setState("Terminate",_21); return false; } } this.transmitState="error"; setTimeout(_2.hitch(this,function(){ this.dispatchPacket(); }),200); return true; },onTerminate:function(_23,_24,_25){ },onProcessProtocolResponse:function(msg){ },onReady:function(_26,_27){ }}); });