Файл: touchSpace/js/pushstream.js
Строк: 1379
<?php
!function(t,e,n){"use strict";var s,i,o,r,a,c,h,u,l,m,p,d,g,f,_,y,S,v,b,C,T,E,P,w,O,I,x,L,A,M,k,N,j,U,B,R,K;t.PushStream||(s={},i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=function(t){return(10>t?"0":"")+t},s.dateToUTCString=function(t){var e=r(t.getUTCHours())+":"+r(t.getUTCMinutes())+":"+r(t.getUTCSeconds());return i[t.getUTCDay()]+", "+r(t.getUTCDate())+" "+o[t.getUTCMonth()]+" "+t.getUTCFullYear()+" "+e+" GMT"},a=function(){var t,e,n,s=arguments[0]||{};for(t=0;t<arguments.length;t++){e=arguments[t];for(n in e)(!e.hasOwnProperty||e.hasOwnProperty(n))&&(s[n]=e[n])}return s},c=/^[],:{}s]*$/,h=/\(?:["\/bfnrt]|u[0-9a-fA-F]{4})/g,u=/"[^"\nr]*"|true|false|null|-?d+(?:.d*)?(?:[eE][+-]?d+)?/g,l=/(?:^|:|,)(?:s*[)+/g,m=function(t){return t.replace(/^s*/,"").replace(/s*$/,"")},s.parseJSON=function(e){if(!e||!S(e))return null;if(e=m(e),t.JSON&&t.JSON.parse)try{return t.JSON.parse(e)}catch(n){throw"Invalid JSON: "+e}if(c.test(e.replace(h,"@").replace(u,"]").replace(l,"")))return Function("return "+e)();throw"Invalid JSON: "+e},p=function(t){var e={};return e[t.tagArgument]="",e[t.timeArgument]="",e[t.eventIdArgument]="",t.messagesControlByArgument&&(e[t.tagArgument]=+t._etag,t._lastModified?e[t.timeArgument]=t._lastModified:t._lastEventId&&(e[t.eventIdArgument]=t._lastEventId)),e},d=function(){return(new Date).getTime()},g=function(){return{_:d()}},f=function(e){var n,s=e;if("object"==typeof e){s="";for(n in e)(!e.hasOwnProperty||e.hasOwnProperty(n))&&(s+="&"+n+"="+t.escape(e[n]));s=s.substring(1)}return s||""},_=function(t,e){return t+(t.indexOf("?")<0?"?":"&")+f(e)},y=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},S=function(t){return"[object String]"===Object.prototype.toString.call(t)},v=function(t){return"[object Date]"===Object.prototype.toString.call(t)},b={logger:null,debug:function(){"debug"===K.LOG_LEVEL&&b._log.apply(b._log,arguments)},info:function(){("info"===K.LOG_LEVEL||"debug"===K.LOG_LEVEL)&&b._log.apply(b._log,arguments)},error:function(){b._log.apply(b._log,arguments)},_log:function(){var n,s,i,o,r;if(b.logger||(n=t.console,n&&n.log&&(n.log.apply?b.logger=n.log:"object"==typeof n.log&&Function.prototype.bind?b.logger=Function.prototype.bind.call(n.log,n):"object"==typeof n.log&&Function.prototype.call&&(b.logger=function(){Function.prototype.call.call(n.log,n,Array.prototype.slice.call(arguments))}))),b.logger&&b.logger.apply(t.console,arguments),s=e.getElementById(K.LOG_OUTPUT_ELEMENT_ID)){for(i="",o=0;o<arguments.length;o++)i+=arguments[o]+" ";s.innerHTML+=i+"n",r=s.innerHTML.split("n"),r.length>100&&(s.innerHTML=r.slice(-100).join("n"))}}},C={_getXHRObject:function(){var e=!1;try{e=new t.XMLHttpRequest}catch(n){try{e=new t.XDomainRequest}catch(s){try{e=new t.ActiveXObject("Msxml2.XMLHTTP")}catch(i){try{e=new t.ActiveXObject("Microsoft.XMLHTTP")}catch(o){e=!1}}}}return e},_send:function(e,s){var i,o,r,c,h;return e=e||{},e.timeout=e.timeout||3e4,i=C._getXHRObject(),i&&e.url?(C.clear(e),i.onreadystatechange=function(){4===i.readyState&&(C.clear(e),e.afterReceive&&e.afterReceive(i),200===i.status?e.success&&e.success(i.responseText):e.error&&e.error(i.status))},e.beforeOpen&&e.beforeOpen(i),o={},r=null,c="GET",s?(r=f(e.data),c="POST"):o=e.data||{},i.open(c,_(e.url,a({},o,g())),!0),e.beforeSend&&e.beforeSend(i),h=function(){try{i.abort()}catch(t){}C.clear(e),e.error(304)},s?(i.setRequestHeader("Accept","application/json"),i.setRequestHeader("Content-type","application/x-www-form-urlencoded")):e.timeoutId=t.setTimeout(h,e.timeout+2e3),i.send(r),i):n},_clear_script:function(t){t&&(t.onerror=t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t))},_clear_timeout:function(t){t.timeoutId=L(t.timeoutId)},clear:function(t){C._clear_timeout(t),C._clear_script(e.getElementById(t.scriptId))},jsonp:function(n){var s,i,o,r,c,h;return n.timeout=n.timeout||3e4,C.clear(n),s=e.head||e.getElementsByTagName("head")[0],i=e.createElement("script"),o=d(),r=function(){var e,s;C.clear(n),e=n.data.callback,e&&(t[e]=function(){t[e]=null}),s=d(),n.error(s-o>n.timeout/2?304:0)},c=function(){C.clear(n),n.load()},i.onerror=r,i.onload=i.onreadystatechange=function(){(!i.readyState||/loaded|complete/.test(i.readyState))&&c()},n.beforeOpen&&n.beforeOpen({}),n.beforeSend&&n.beforeSend({}),n.timeoutId=t.setTimeout(r,n.timeout+2e3),n.scriptId=n.scriptId||d(),h=n.data.callback,h&&(t[h]=function(){t[h]=null}),n.data.callback=n.scriptId+"_onmessage_"+d(),t[n.data.callback]=n.success,i.setAttribute("src",_(n.url,a({},n.data,g()))),i.setAttribute("async","async"),i.setAttribute("id",n.scriptId),s.insertBefore(i,s.firstChild),n},load:function(t){return C._send(t,!1)},post:function(t){return C._send(t,!0)}},T=function(e){return e?t.escape(e):""},E=function(e){return e?t.unescape(e):""},s.parseMessage=function(t,e){var n,i=t;return S(t)&&(i=s.parseJSON(t)),n={id:i[e.jsonIdKey],channel:i[e.jsonChannelKey],text:S(i[e.jsonTextKey])?E(i[e.jsonTextKey]):i[e.jsonTextKey],tag:i[e.jsonTagKey],time:i[e.jsonTimeKey],eventid:i[e.jsonEventIdKey]||""}},P=function(t){return t.backtrack?".b"+ +t.backtrack:""},w=function(t,e){var n,s="";for(n in t)(!t.hasOwnProperty||t.hasOwnProperty(n))&&(s+="/"+n+(e?P(t[n]):""));return s},O=function(t,e,n,s){var i,o,r=t.wrapper.type===N.TYPE,c=t.useSSL,h=r?c?"wss://":"ws://":c?"https://":"http://";return h+=t.host,h+=!c&&80===t.port||c&&443===t.port?"":":"+t.port,h+=e,i=w(t.channels,s),t.channelsByArgument?(o={},o[t.channelsArgument]=i.substring(1),n=a({},n,o)):h+=i,_(h,n)},I=function(t){var e,n="",s=t.useSSL?"https://":"http://";s+=t.host,s+=80!==t.port&&443!==t.port?":"+t.port:"",s+=t.urlPrefixPublisher;for(e in t.channels)if(!t.channels.hasOwnProperty||t.channels.hasOwnProperty(e)){n=e;break}return s+="?id="+n},s.extract_xss_domain=function(t){var e,n;return t.match(/^(d{1,3}.){3}d{1,3}$/)?t:(e=t.split("."),n=Math.max(e.length-1,t.match(/(w{4,}.w{2}|.w{3,})$/)?2:3),e.slice(-1*n).join("."))},x=function(t,e){return function(){return t.apply(e,arguments)}},L=function(e){return e&&t.clearTimeout(e),null},A=function(t){b.info("["+this.type+"] message received",arguments);var e=s.parseMessage(t.data,this.pushstream);e.tag&&(this.pushstream._etag=e.tag),e.time&&(this.pushstream._lastModified=e.time),e.eventid&&(this.pushstream._lastEventId=e.eventid),this.pushstream._onmessage(e.text,e.id,e.channel,e.eventid,!0)},M=function(){this.pushstream._onopen(),b.info("["+this.type+"] connection opened")},k=function(e){b.info("["+this.type+"] error (disconnected by server):",e),(this.pushstream.readyState!==K.OPEN||this.type!==j.TYPE||"error"!==e.type||this.connection.readyState!==t.EventSource.CONNECTING)&&(this._closeCurrentConnection(),this.pushstream._onerror({type:e&&("load"===e.type||"close"===e.type)||this.pushstream.readyState===K.CONNECTING?"load":"timeout"}))},N=function(e){var n;if(/Safari/i.test(navigator.userAgent)&&(n=navigator.userAgent.match(/Version/([d]+)/i))&&(n=+n[1],6>n))throw"WebSocket not supported";if(!t.WebSocket&&!t.MozWebSocket)throw"WebSocket not supported";this.type=N.TYPE,this.pushstream=e,this.connection=null},N.TYPE="WebSocket",N.prototype={connect:function(){var e,n;this._closeCurrentConnection(),e=a({},this.pushstream.extraParams(),g(),p(this.pushstream)),n=O(this.pushstream,this.pushstream.urlPrefixWebsocket,e,!this.pushstream._useControlArguments()),this.connection=t.WebSocket?new t.WebSocket(n):new t.MozWebSocket(n),this.connection.onerror=x(k,this),this.connection.onclose=x(k,this),this.connection.onopen=x(M,this),this.connection.onmessage=x(A,this),b.info("[WebSocket] connecting to:",n)},disconnect:function(){this.connection&&(b.debug("[WebSocket] closing connection to:",this.connection.URL),this.connection.onclose=null,this._closeCurrentConnection(),this.pushstream._onclose())},_closeCurrentConnection:function(){if(this.connection){try{this.connection.close()}catch(t){}this.connection=null}},sendMessage:function(t){this.connection&&this.connection.send(t)}},j=function(e){if(!t.EventSource)throw"EventSource not supported";this.type=j.TYPE,this.pushstream=e,this.connection=null},j.TYPE="EventSource",j.prototype={connect:function(){var e,n;this._closeCurrentConnection(),e=a({},this.pushstream.extraParams(),g(),p(this.pushstream)),n=O(this.pushstream,this.pushstream.urlPrefixEventsource,e,!this.pushstream._useControlArguments()),this.connection=new t.EventSource(n),this.connection.onerror=x(k,this),this.connection.onopen=x(M,this),this.connection.onmessage=x(A,this),b.info("[EventSource] connecting to:",n)},disconnect:function(){this.connection&&(b.debug("[EventSource] closing connection to:",this.connection.URL),this.connection.onclose=null,this._closeCurrentConnection(),this.pushstream._onclose())},_closeCurrentConnection:function(){if(this.connection){try{this.connection.close()}catch(t){}this.connection=null}}},U=function(t){this.type=U.TYPE,this.pushstream=t,this.connection=null,this.url=null,this.frameloadtimer=null,this.pingtimer=null,this.iframeId="PushStreamManager_"+t.id},U.TYPE="Stream",U.prototype={connect:function(){var t,n;this._closeCurrentConnection(),t=s.extract_xss_domain(this.pushstream.host);try{e.domain=t}catch(i){b.error("[Stream] (warning) problem setting document.domain = "+t+" (OBS: IE8 does not support set IP numbers as domain)")}n=a({},this.pushstream.extraParams(),g(),{streamid:this.pushstream.id},p(this.pushstream)),this.url=O(this.pushstream,this.pushstream.urlPrefixStream,n,!this.pushstream._useControlArguments()),b.debug("[Stream] connecting to:",this.url),this.loadFrame(this.url)},disconnect:function(){this.connection&&(b.debug("[Stream] closing connection to:",this.url),this._closeCurrentConnection(),this.pushstream._onclose())},_clear_iframe:function(){var t=e.getElementById(this.iframeId);t&&(t.onload=null,t.src="about:blank",t.parentNode&&t.parentNode.removeChild(t))},_closeCurrentConnection:function(){this._clear_iframe(),this.connection&&(this.pingtimer=L(this.pingtimer),this.frameloadtimer=L(this.frameloadtimer),this.connection=null,this.transferDoc=null,"function"==typeof t.CollectGarbage&&t.CollectGarbage())},loadFrame:function(n){var s,i,o;this._clear_iframe();try{s=new t.ActiveXObject("htmlfile"),s.open(),s.write('<html><script>document.domain="'+e.domain+'";</script></html>'),s.parentWindow.PushStream=K,s.close(),i=s.createElement("div"),s.appendChild(i),i.innerHTML='<iframe src="'+n+'"></iframe>',this.connection=i.getElementsByTagName("IFRAME")[0],this.connection.onload=x(k,this),this.transferDoc=s}catch(r){o=e.createElement("IFRAME"),o.style.width="1px",o.style.height="1px",o.style.border="none",o.style.position="absolute",o.style.top="-10px",o.style.marginTop="-10px",o.style.zIndex="-20",o.PushStream=K,e.body.appendChild(o),o.setAttribute("src",n),o.onload=x(k,this),this.connection=o}this.connection.setAttribute("id",this.iframeId),this.frameloadtimer=t.setTimeout(x(k,this),this.pushstream.timeout)},register:function(t){this.frameloadtimer=L(this.frameloadtimer),t.p=x(this.process,this),this.connection.onload=x(this._onframeloaded,this),this.pushstream._onopen(),this.setPingTimer(),b.info("[Stream] frame registered")},process:function(t,e,n,s,i,o){this.pingtimer=L(this.pingtimer),b.info("[Stream] message received",arguments),-1!==t&&(o&&(this.pushstream._etag=o),i&&(this.pushstream._lastModified=i),s&&(this.pushstream._lastEventId=s)),this.pushstream._onmessage(E(n),t,e,s||"",!0),this.setPingTimer()},_onframeloaded:function(){b.info("[Stream] frame loaded (disconnected by server)"),this.connection.onload=null,this.disconnect()},setPingTimer:function(){this.pingtimer&&L(this.pingtimer),this.pingtimer=t.setTimeout(x(k,this),this.pushstream.pingtimeout)}},B=function(t){this.type=B.TYPE,this.pushstream=t,this.connection=null,this.opentimer=null,this.messagesQueue=[],this._linkedInternalListen=x(this._internalListen,this),this.xhrSettings={timeout:this.pushstream.timeout,data:{},url:null,success:x(this.onmessage,this),error:x(this.onerror,this),load:x(this.onload,this),beforeSend:x(this.beforeSend,this),afterReceive:x(this.afterReceive,this)}},B.TYPE="LongPolling",B.prototype={connect:function(){var e,n,i,o;this.messagesQueue=[],this._closeCurrentConnection(),this.urlWithBacktrack=O(this.pushstream,this.pushstream.urlPrefixLongpolling,{},!0),this.urlWithoutBacktrack=O(this.pushstream,this.pushstream.urlPrefixLongpolling,{},!1),this.xhrSettings.url=this.urlWithBacktrack,e=s.extract_xss_domain(this.pushstream.host),n=s.extract_xss_domain(t.location.hostname),i=this.pushstream.port,o=t.location.port?+t.location.port:this.pushstream.useSSL?443:80,this.useJSONP=e!==n||i!==o||this.pushstream.useJSONP,this.xhrSettings.scriptId="PushStreamManager_"+this.pushstream.id,this.useJSONP&&(this.pushstream.messagesControlByArgument=!0),this._internalListen(),this.opentimer=t.setTimeout(x(M,this),100),b.info("[LongPolling] connecting to:",this.xhrSettings.url)},_listen:function(){this._internalListenTimeout&&L(this._internalListenTimeout),this._internalListenTimeout=t.setTimeout(this._linkedInternalListen,100)},_internalListen:function(){this.pushstream._keepConnected&&(this.xhrSettings.url=this.pushstream._useControlArguments()?this.urlWithoutBacktrack:this.urlWithBacktrack,this.xhrSettings.data=a({},this.pushstream.extraParams(),this.xhrSettings.data,p(this.pushstream)),this.useJSONP?this.connection=C.jsonp(this.xhrSettings):this.connection||(this.connection=C.load(this.xhrSettings)))},disconnect:function(){this.connection&&(b.debug("[LongPolling] closing connection to:",this.xhrSettings.url),this._closeCurrentConnection(),this.pushstream._onclose())},_closeCurrentConnection:function(){if(this.opentimer=L(this.opentimer),this.connection){try{this.connection.abort()}catch(t){try{C.clear(this.connection)}catch(e){}}this.connection=null,this.xhrSettings.url=null}},beforeSend:function(t){this.pushstream.messagesControlByArgument||(t.setRequestHeader("If-None-Match",this.pushstream._etag),t.setRequestHeader("If-Modified-Since",this.pushstream._lastModified))},afterReceive:function(t){this.pushstream.messagesControlByArgument||(this.pushstream._etag=t.getResponseHeader("Etag"),this.pushstream._lastModified=t.getResponseHeader("Last-Modified")),this.connection=null},onerror:function(t){this.pushstream._keepConnected&&(304===t?this._listen():(b.info("[LongPolling] error (disconnected by server):",t),this._closeCurrentConnection(),this.pushstream._onerror({type:403===t||this.pushstream.readyState===K.CONNECTING?"load":"timeout"})))},onload:function(){this._listen()},onmessage:function(t){var e,n,i,o;for(this._internalListenTimeout&&L(this._internalListenTimeout),b.info("[LongPolling] message received",t),e=null,n=y(t)?t:t.replace(/}{/g,"}rn{").split("rn"),i=0;i<n.length;i++)n[i]&&(e=s.parseMessage(n[i],this.pushstream),this.messagesQueue.push(e),this.pushstream.messagesControlByArgument&&e.time&&(this.pushstream._etag=e.tag,this.pushstream._lastModified=e.time));for(this._listen();this.messagesQueue.length>0;)o=this.messagesQueue.shift(),this.pushstream._onmessage(o.text,o.id,o.channel,o.eventid,0===this.messagesQueue.length)}},R=[],K=function(e){var n,s;for(e=e||{},this.id=R.push(this)-1,this.useSSL=e.useSSL||!1,this.host=e.host||t.location.hostname,this.port=+(e.port||(this.useSSL?443:80)),this.timeout=e.timeout||3e4,this.pingtimeout=e.pingtimeout||3e4,this.reconnectOnTimeoutInterval=e.reconnectOnTimeoutInterval||3e3,this.reconnectOnChannelUnavailableInterval=e.reconnectOnChannelUnavailableInterval||6e4,this.lastEventId=e.lastEventId||null,this.messagesPublishedAfter=e.messagesPublishedAfter,this.messagesControlByArgument=e.messagesControlByArgument||!1,this.tagArgument=e.tagArgument||"tag",this.timeArgument=e.timeArgument||"time",this.eventIdArgument=e.eventIdArgument||"eventid",this.useJSONP=e.useJSONP||!1,this._reconnecttimer=null,this._etag=0,this._lastModified=null,this._lastEventId=null,this.urlPrefixPublisher=e.urlPrefixPublisher||"/pub",this.urlPrefixStream=e.urlPrefixStream||"/sub",this.urlPrefixEventsource=e.urlPrefixEventsource||"/ev",this.urlPrefixLongpolling=e.urlPrefixLongpolling||"/lp",this.urlPrefixWebsocket=e.urlPrefixWebsocket||"/ws",this.jsonIdKey=e.jsonIdKey||"id",this.jsonChannelKey=e.jsonChannelKey||"channel",this.jsonTextKey=e.jsonTextKey||"text",this.jsonTagKey=e.jsonTagKey||"tag",this.jsonTimeKey=e.jsonTimeKey||"time",this.jsonEventIdKey=e.jsonEventIdKey||"eventid",this.modes=(e.modes||"eventsource|websocket|stream|longpolling").split("|"),this.wrappers=[],this.wrapper=null,this.onchanneldeleted=e.onchanneldeleted||null,this.onmessage=e.onmessage||null,this.onerror=e.onerror||null,this.onstatuschange=e.onstatuschange||null,this.extraParams=e.extraParams||function(){return{}},this.channels={},this.channelsCount=0,this.channelsByArgument=e.channelsByArgument||!1,this.channelsArgument=e.channelsArgument||"channels",n=0;n<this.modes.length;n++)try{switch(s=null,this.modes[n]){case"websocket":s=new N(this);break;case"eventsource":s=new j(this);break;case"longpolling":s=new B(this);break;case"stream":s=new U(this)}this.wrappers[this.wrappers.length]=s}catch(i){b.info(i)}this.readyState=0},K.LOG_LEVEL="error",K.LOG_OUTPUT_ELEMENT_ID="Log4jsLogOutput",K.CLOSED=0,K.CONNECTING=1,K.OPEN=2,K.prototype={addChannel:function(t,e){if(T(t)!==t)throw"Invalid channel name! Channel has to be a set of [a-zA-Z0-9]";if(b.debug("entering addChannel"),n!==this.channels[t])throw"Cannot add channel "+t+": already subscribed";e=e||{},b.info("adding channel",t,e),this.channels[t]=e,this.channelsCount++,this.readyState!==K.CLOSED&&this.connect(),b.debug("leaving addChannel")},removeChannel:function(t){this.channels[t]&&(b.info("removing channel",t),delete this.channels[t],this.channelsCount--)},removeAllChannels:function(){b.info("removing all channels"),this.channels={},this.channelsCount=0},_setState:function(t){this.readyState!==t&&(b.info("status changed",t),this.readyState=t,this.onstatuschange&&this.onstatuschange(this.readyState))},connect:function(){var t,n,s;if(b.debug("entering connect"),!this.host)throw"PushStream host not specified";if(isNaN(this.port))throw"PushStream port not specified";if(!this.channelsCount)throw"No channels specified";if(0===this.wrappers.length)throw"No available support for this browser";if(this._keepConnected=!0,this._lastUsedMode=0,t=e.cookie.match(/lpm=([^s;]+)/)){n=decodeURIComponent(t[1]);for(s in this.wrappers)if(this.wrappers[s].type==n){this._lastUsedMode=s;break}}this._connect(),b.debug("leaving connect")},disconnect:function(){b.debug("entering disconnect"),this._keepConnected=!1,this._disconnect(),this._setState(K.CLOSED),b.info("disconnected"),b.debug("leaving disconnect")},_useControlArguments:function(){return this.messagesControlByArgument&&(null!==this._lastModified||null!==this._lastEventId)},_connect:function(){var t,e;null===this._lastEventId&&(this._lastEventId=this.lastEventId),null===this._lastModified&&(t=this.messagesPublishedAfter,v(t)||(e=+this.messagesPublishedAfter,e>0?(t=new Date,t.setTime(t.getTime()-1e3*e)):0>e&&(t=new Date(0))),v(t)&&(this._lastModified=s.dateToUTCString(t))),this._disconnect(),this._setState(K.CONNECTING),this.wrapper=this.wrappers[this._lastUsedMode++%this.wrappers.length];try{this.wrapper.connect()}catch(n){this.wrapper&&this.wrapper.disconnect()}},_disconnect:function(){this._reconnecttimer=L(this._reconnecttimer),this.wrapper&&this.wrapper.disconnect()},_onopen:function(){this._reconnecttimer=L(this._reconnecttimer),this._setState(K.OPEN),this._lastUsedMode>0&&(this._lastUsedMode--,-1==e.cookie.indexOf("hws=1")&&this.wrapper.type!=N.TYPE&&(e.cookie="lpm="+encodeURIComponent(this.wrapper.type)+"; path=/; domain=."+base_domain()+"; expires="+new Date(2038,1,1).toUTCString())),this.wrapper.type==N.TYPE&&(e.cookie="hws=1; path=/; domain=."+base_domain()+"; expires="+new Date(2038,1,1).toUTCString())},_onclose:function(){this._reconnecttimer=L(this._reconnecttimer),this._setState(K.CLOSED),this._reconnect(this.reconnectOnTimeoutInterval)},_onmessage:function(t,e,n,s,i){b.debug("message",t,e,n,s,i),-2===e?this.onchanneldeleted&&this.onchanneldeleted(n):e>0&&this.onmessage&&this.onmessage(t,e,n,s,i)},_onerror:function(t){this._setState(K.CLOSED),this._reconnect("timeout"===t.type?this.reconnectOnTimeoutInterval:this.reconnectOnChannelUnavailableInterval),this.onerror&&this.onerror(t)},_reconnect:function(e){this._keepConnected&&!this._reconnecttimer&&this.readyState!==K.CONNECTING&&(b.info("trying to reconnect in",e),this._reconnecttimer=t.setTimeout(x(this._connect,this),e))},sendMessage:function(t,e,n){t=T(t),this.wrapper.type===N.TYPE?(this.wrapper.sendMessage(t),e&&e()):C.post({url:I(this),data:t,success:e,error:n})}},K.sendMessage=function(t,e,n,s){C.post({url:t,data:T(e),success:n,error:s})},K.register=function(t){var e=t.window.location.href.match(/streamid=([0-9]*)&?/);e[1]&&R[e[1]]&&R[e[1]].wrapper.register(t)},K.unload=function(){for(var t=0;t<R.length;t++)try{R[t].disconnect()}catch(e){}},t.PushStream=K,t.PushStreamManager=R,t.attachEvent&&t.attachEvent("onunload",K.unload),t.addEventListener&&t.addEventListener.call(t,"unload",K.unload,!1))}(window,document);
?>