Вход Регистрация
Файл: touchSpace/js/spaces.pushstream.js
Строк: 114
<?php
window
.Spaces=window.Spaces||{},Spaces.PushStream=function(){this.callbacks={message:{},connect:{},disconnect:{},error:{}},PushStream.apply(this,arguments),this.onmessage=this._onMessage,this.onerror=function(e){console.error("[LP] error:",e,"; time: ",(new Date).toUTCString()),this._trigger("error",arguments)},this.onstatuschange=function(e){switch(e){case PushStream.CLOSED:console.error("[LP] disconnected, time: ",(new Date).toUTCString()),this._trigger("disconnect",[]);break;case PushStream.OPEN:console.info("[LP] connected, time: ",(new Date).toUTCString()),this._trigger("connect",[]);break;case PushStream.CONNECTING:console.debug("[LP] start connecting, time: ",(new Date).toUTCString()),this._trigger("connecting",[])}}},extend(Spaces.PushStream.prototype,PushStream.prototype,{addMessageHandler:function(e,t){return this.on("message",e,t)},deleteMessageHandler:function(e){return this.off("message",e)},_onMessage:function(){this._trigger("message",arguments)},on:function(e,t,n){return this.callbacks[e][t]=n,this},off:function(e,t){return delete this.callbacks[e][t],this},_trigger:function(e,t){var n,s;for(n in this.callbacks[e])if(s=this.callbacks[e][n])try{s.apply(this,t)}catch(r){console.error("PushStream handler ("+e+", "+n+") error:",r.message,r.stack?"n"+r.stack:r)}else this.off(e,n)}}),Spaces.PushStream.create=function(e){var t=new Spaces.PushStream(extend({timeout:3e4,modes:"websocket|longpolling",useJSONP:!0,messagesControlByArgument:!1,urlPrefixLongpolling:"/lpex",reconnectOnTimeoutInterval:1e3,reconnectOnChannelUnavailableInterval:1e3},e));return e.host&&($(window).load(function(){setTimeout(function(){t.readyState==PushStream.CLOSED&&pushstream.connect()},10)}),setTimeout(function(){t.readyState==PushStream.CLOSED&&pushstream.connect()},7e3)),t};
?>
Онлайн: 0
Реклама