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