//>>built
define("dojox/socket","dojo/_base/array,dojo/_base/lang,dojo/_base/xhr,dojo/aspect,dojo/on,dojo/Evented,dojo/_base/url".split(","),function(j,k,q,n,o,r,s){var p=window.WebSocket,b=function(a){"string"==typeof a&&(a={url:a});return p?b.WebSocket(a,!0):b.LongPoll(a)};b.WebSocket=function(a,h){var e=new p(new s((document.baseURI||window.location.href).replace(/^http/i,"ws"),a.url));e.on=function(a,f){e.addEventListener(a,f,!0)};var i;n.after(e,"onopen",function(){i=!0},!0);n.after(e,"onclose",function(){i||
h&&b.replace(e,b.LongPoll(a),!0)},!0);return e};b.replace=function(a,h,e){a.send=k.hitch(h,"send");a.close=k.hitch(h,"close");var b=function(c){(h.addEventListener||h.on).call(h,c,function(c){o.emit(a,c.type,c)},!0)};e&&b("open");j.forEach(["message","close","error"],b)};b.LongPoll=function(a){var b=!1,e=!0,i,c=[],f,l,d={send:function(t){var m=k.delegate(a);m.rawBody=t;clearTimeout(i);var g=e?(e=!1)||d.firstRequest(m):d.transport(m);c.push(g);g.then(function(b){d.readyState=1;c.splice(j.indexOf(c,
g),1);c.length||(i=setTimeout(l,a.interval));b&&f("message",{data:b},g)},function(a){c.splice(j.indexOf(c,g),1);if(!b&&(f("error",{error:a},g),!c.length))d.readyState=3,f("close",{wasClean:!1},g)});return g},close:function(){d.readyState=2;b=!0;var a;for(a=0;a<c.length;a++)c[a].cancel();d.readyState=3;f("close",{wasClean:!0})},transport:a.transport||q.post,args:a,url:a.url,readyState:0,CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3,on:r.prototype.on,firstRequest:function(a){var b=a.headers||(a.headers={});
b.Pragma="start-long-poll";try{return this.transport(a)}finally{delete b.Pragma}}};f=function(a,b,c){if(d["on"+a])b.ioArgs=c&&c.ioArgs,b.type=a,o.emit(d,a,b)};l=function(){0==d.readyState&&f("open",{});c.length||d.send()};d.connect=d.on;setTimeout(l);return d};return b});