WEB_SOCKET_SWF_LOCATION="/utils/socket.io/support/socket.io-client/lib/vendor/web-socket-js/WebSocketMain.swf";function Multiplexer(a){this._channels={};this._url=a;this._username=this._loginKey=""}Multiplexer.prototype.login=function(a,b){this._loginKey=a;this._username=b};Multiplexer.prototype.subscribe=function(a,b){this._channels[a]||(this._channels[a]={cursor:null,callbacks:[]});a=this._channels[a].callbacks;for(var c=0;c<a.length;c++)if(a[c]===b)return this;a.push(b);return this};
Multiplexer.prototype.unsubscribe=function(a,b){if(!this._channels[a])return this;if(b==null){this._channels[a].callbacks=[];delete this._channels[a];return this}a=this._channels[a].callbacks;for(var c=0;c<a.length;c++)if(a[c]===b){a.splice(c,1);return this}return this};
Multiplexer.prototype.run=function(){this._socket!=undefined&&this._socket.disconnect();this._socket=new io.Socket(this._url,{rememberTransport:false,port:7779});this._socket.connect();var a=this;this._socket.addEvent("message",function(b){if(b.channel!==undefined&&b.channel in a._channels)for(var c=a._channels[b.channel].callbacks,d=0;d<c.length;d++)setTimeout(c[d](b.data),1)});this._socket.addEvent("connect",function(){try{for(var b in a._channels)a._socket.send({channel:b,command:"subscribe",loginKey:a._loginKey,
username:a._username})}catch(c){}});this._socket.addEvent("connect_failed",function(){setTimeout(function(){a.run()},100)});this._socket.addEvent("disconnect",function(){setTimeout(function(){a.run()},30)});this._socket.addEvent("reconnect_failed",function(){setTimeout(function(){a.run()},30)})};Multiplexer.prototype.stop=function(){this._socket&&this._socket.disconnect()};var multiplexer=new Multiplexer(document.domain);

