diff --git a/dist/socket.io.js b/dist/socket.io.js index 3cceb85d..23803964 100644 --- a/dist/socket.io.js +++ b/dist/socket.io.js @@ -1529,7 +1529,7 @@ if (xhr.status == 200) { complete(xhr.responseText); } else { - self.onError(xhr.responseText); + !self.reconnecting && self.onError(xhr.responseText); } } }; diff --git a/dist/socket.io.min.js b/dist/socket.io.min.js index 5b6ae885..38516b44 100644 --- a/dist/socket.io.min.js +++ b/dist/socket.io.min.js @@ -1,2 +1,2 @@ /*! Socket.IO.min.js build:0.7.0, production. Copyright(c) 2011 LearnBoost MIT Licensed */ -(function(a){var b=a;b.version="0.7.0",b.protocol=1,b.transports=[],b.j=[],b.sockets={},b.connect=function(a,c){var d=b.util.parseUri(a),e,f;"undefined"!=typeof document&&(d.host=d.host||document.domain,d.port=d.port||document.location.port),e=b.util.uniqueUri(d);if(c||!b.sockets[e])f=new b.Socket({host:d.host,secure:d.protocol=="https://",port:d.port||80});!c&&f&&(this.sockets[e]=f),f=f||this.sockets[e];return f.of(d.path.length>1?d.path:"")}})("object"==typeof module?module.exports:window.io={}),function(a){var b=a.util={},c=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.parseUri=function(a){var b=c.exec(a||""),e={},f=14;while(f--)e[d[f]]=b[f]||"";return e},b.uniqueUri=function(a){var b=a.protocol,c=a.host,d=a.port;"undefined"!=typeof document?(c=c||document.domain,d=d||(b=="https"&&document.location.protocol!=="https:"?443:document.location.port)):(c=c||"localhost",!d&&b=="https"&&(d=443));return(b||"http")+"://"+c+":"+(d||80)};var e=!1;b.load=function(a){if(document.readyState==="complete"||e)return a();b.on(window,"load",a,!1)},b.on=function(a,b,c,d){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c,d)};var f="undefined"!=typeof window&&window.XMLHttpRequest&&function(){try{var a=new XMLHttpRequest}catch(b){return!1}return a.withCredentials!=undefined}();b.request=function(a){if("undefined"!=typeof window){if(a&&window.XDomainRequest)return new XDomainRequest;if(window.XMLHttpRequest&&(!a||f))return new XMLHttpRequest;if(!a)try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}return null},"undefined"!=typeof window&&b.load(function(){e=!0}),b.defer=function(a){if(!b.ua.webkit)return a();b.load(function(){setTimeout(a,100)})},b.merge=function(a,b,c,d){var e=d||[],f=typeof c=="undefined"?2:c,g;for(g in b)b.hasOwnProperty(g)&&this.indexOf(e,g)<0&&(typeof a[g]!="object"||!f?(a[g]=b[g],e.push(b[g])):this.merge(a[g],b[g],f-1,e));return a},b.mixin=function(a,c){b.merge(a.prototype,c.prototype)},b.inherit=function(a,c){a.prototype=new c,b.merge(a,c)},b.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},b.intersect=function(a,c){var d=[],e=a.length>c.length?a:c,f=a.length>c.length?c:a;for(var g=0,h=f.length;g0&&a.splice(0,1)[0]!=c.transport.name);a.length&&(c.transport=c.getTransport(a),c.connect())}(!c.remainingTransports||c.remainingTransports.length==0)&&c.publish("connect_failed")}c.remainingTransports&&c.remainingTransports.length==0&&delete c.remainingTransports},c.options["connect timeout"])),a&&typeof a=="function"&&c.once("connect",a))});return this},c.prototype.packet=function(a){this.open?this.transport.packet(a):this.buffer.push(a);return this},c.prototype.disconnect=function(a){if(this.connected){this.open&&this.of("").packet({type:"disconnect"});var c=b.util.request();c.open("GET",this.resource+"/"+b.protocol+"/"+this.sessionid),a&&(c.sync=!0),this.onDisconnect()}return this},c.prototype.isXDomain=function(){var a=window.location.port||80;return this.options.host!==document.domain||this.options.port!=a},c.prototype.onConnect=function(){this.connected=!0,this.connecting=!1,this.publish("connect")},c.prototype.onOpen=function(){this.open=!0;if(this.buffer.length){for(var a=0,b=this.buffer.length;a=b?a.redoTransports?(a.publish("reconnect_failed"),d()):(a.on("connect_failed",e),a.options["try multiple transports"]=!0,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay*=2,a.connect(),a.publish("reconnecting",a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(e,a.reconnectionDelay))}}function d(){a.connected&&a.publish("reconnect",a.transport.name,a.reconnectionAttempts),a.removeListener("connect_failed",e),a.removeListener("connect",e),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options["try multiple transports"]=c}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var a=this,b=this.options["max reconnection attempts"],c=this.options["try multiple transports"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(e,this.reconnectionDelay),this.on("connect",e)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(a,b){this.namespace=a,this.name=b}function c(a,b){this.socket=a,this.name=b||"",this.flags={},this.json=new d(this,"json"),this.ackPackets=0,this.acks={}}a.SocketNamespace=c,b.util.mixin(c,b.EventEmitter),c.prototype.$emit=b.EventEmitter.prototype.emit,c.prototype.packet=function(a){a.endpoint=this.name,this.socket.packet(a),this.flags={};return this},c.prototype.send=function(a,b){var c={type:this.flags.json?"json":"message",data:a};"function"==typeof b&&(c.id=++this.ackPackets,c.ack=b.length?"data":!0,this.acks[c.id]=b);return this.packet(c)},c.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:"event",name:a};"function"==typeof c&&(d.id=++this.ackPackets,d.ack=c.length?"data":!0,this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b;return this.packet(d)},c.prototype.onPacket=function(a){function e(){d.packet({type:"ack",args:b.util.toArray(arguments),ackId:a.id})}var c=a.ack=="data",d=this;switch(a.type){case"connect":case"disconnect":this.$emit(a.type);break;case"message":case"json":var f=["message",a.data];c&&f.push(e),this.emit.apply(socket,f);break;case"event":var f=[a.name].concat(a.args);c&&f.push(e),this.$emit.apply(this,f);break;case"ack":this.acks[a.ackId]&&(this.acks[a.ackId].apply(this,a.args),delete this.acks[a.ackId])}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.apply(this,arguments),this.name="websocket"}a.websocket=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.websocket=new WebSocket(this.prepareUrl());var a=this;this.websocket.onopen=function(){a.onOpen()},this.websocket.onmessage=function(b){a.onData(b.data)},this.websocket.onclose=function(){a.onClose()},this.websocket.onerror=function(b){a.onError(b)};return this},c.prototype.send=function(a){this.websocket.send(a);return this},c.prototype.close=function(){this.websocket.close();return this},c.prototype.onError=function(a){this.socket.onError(a)},c.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},c.prototype.prepareUrl=function(){return this.scheme()+"://"+this.socket.options.host+":"+this.socket.options.port+"/"+this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid},c.check=function(){return"WebSocket"in window&&!("__addTask"in WebSocket)},c.xdomainCheck=function(){return!0},b.transports.push("websocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(){b.Transport.websocket.apply(this,arguments),this.name="flashsocket"}a.flashsocket=c,b.util.inherit(c,b.Transport.websocket),c.prototype.open=function(){var a=this,c=arguments;WebSocket.__addTask(function(){b.Transport.websocket.prototype.open.apply(a,c)});return this},c.prototype.send=function(){var a=this,c=arguments;WebSocket.__addTask(function(){b.Transport.websocket.prototype.send.apply(a,c)});return this},c.check=function(a){if(typeof WebSocket=="undefined"||!("__initialize"in WebSocket)||!swfobject)return!1;var b=swfobject.getFlashPlayerVersion().major>=10;if(b){if(typeof WEB_SOCKET_SWF_LOCATION=="undefined"){var c="/socket.io/static/flashsocket/WebSocketMain";c=c+(a.isXDomain()?"Insecure":"")+".swf",WEB_SOCKET_SWF_LOCATION=c}WebSocket.__initialize()}return b},c.xdomainCheck=function(){return!0},typeof window!="undefined"&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),b.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);var swfobject=function(){function V(b){var c=/[\\\"<>\.;]/,d=c.exec(b)!=null;return d&&typeof encodeURIComponent!=a?encodeURIComponent(b):b}function U(a,b){if(!!x){var c=b?"visible":"hidden";t&&P(a)?P(a).style.visibility=c:T("#"+a,"visibility:"+c)}}function T(c,d,e,f){if(!y.ie||!y.mac){var g=i.getElementsByTagName("head")[0];if(!g)return;var h=e&&typeof e=="string"?e:"screen";f&&(v=null,w=null);if(!v||w!=h){var j=Q("style");j.setAttribute("type","text/css"),j.setAttribute("media",h),v=g.appendChild(j),y.ie&&y.win&&typeof i.styleSheets!=a&&i.styleSheets.length>0&&(v=i.styleSheets[i.styleSheets.length-1]),w=h}y.ie&&y.win?v&&typeof v.addRule==b&&v.addRule(c,d):v&&typeof i.createTextNode!=a&&v.appendChild(i.createTextNode(c+" {"+d+"}"))}}function S(a){var b=y.pv,c=a.split(".");c[0]=parseInt(c[0],10),c[1]=parseInt(c[1],10)||0,c[2]=parseInt(c[2],10)||0;return b[0]>c[0]||b[0]==c[0]&&b[1]>c[1]||b[0]==c[0]&&b[1]==c[1]&&b[2]>=c[2]?!0:!1}function R(a,b,c){a.attachEvent(b,c),o[o.length]=[a,b,c]}function Q(a){return i.createElement(a)}function P(a){var b=null;try{b=i.getElementById(a)}catch(c){}return b}function O(a){var b=P(a);if(b){for(var c in b)typeof b[c]=="function"&&(b[c]=null);b.parentNode.removeChild(b)}}function N(a){var b=P(a);b&&b.nodeName=="OBJECT"&&(y.ie&&y.win?(b.style.display="none",function(){b.readyState==4?O(a):setTimeout(arguments.callee,10)}()):b.parentNode.removeChild(b))}function M(a,b,c){var d=Q("param");d.setAttribute("name",b),d.setAttribute("value",c),a.appendChild(d)}function L(c,d,f){var g,h=P(f);if(y.wk&&y.wk<312)return g;if(h){typeof c.id==a&&(c.id=f);if(y.ie&&y.win){var i="";for(var j in c)c[j]!=Object.prototype[j]&&(j.toLowerCase()=="data"?d.movie=c[j]:j.toLowerCase()=="styleclass"?i+=' class="'+c[j]+'"':j.toLowerCase()!="classid"&&(i+=" "+j+'="'+c[j]+'"'));var k="";for(var l in d)d[l]!=Object.prototype[l]&&(k+='');h.outerHTML='"+k+"",n[n.length]=c.id,g=P(c.id)}else{var m=Q(b);m.setAttribute("type",e);for(var o in c)c[o]!=Object.prototype[o]&&(o.toLowerCase()=="styleclass"?m.setAttribute("class",c[o]):o.toLowerCase()!="classid"&&m.setAttribute(o,c[o]));for(var p in d)d[p]!=Object.prototype[p]&&p.toLowerCase()!="movie"&&M(m,p,d[p]);h.parentNode.replaceChild(m,h),g=m}}return g}function K(a){var c=Q("div");if(y.win&&y.ie)c.innerHTML=a.innerHTML;else{var d=a.getElementsByTagName(b)[0];if(d){var e=d.childNodes;if(e){var f=e.length;for(var g=0;g0)for(var c=0;c0){var g=P(d);if(g)if(S(m[c].swfVersion)&&!(y.wk&&y.wk<312))U(d,!0),e&&(f.success=!0,f.ref=G(d),e(f));else if(m[c].expressInstall&&H()){var h={};h.data=m[c].expressInstall,h.width=g.getAttribute("width")||"0",h.height=g.getAttribute("height")||"0",g.getAttribute("class")&&(h.styleclass=g.getAttribute("class")),g.getAttribute("align")&&(h.align=g.getAttribute("align"));var i={},j=g.getElementsByTagName("param"),k=j.length;for(var l=0;l= 10.0.0 is required.");return}location.protocol=="file:"&&a.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(a,b,c,d,e){var f=this;f.__id=WebSocket.__nextId++,WebSocket.__instances[f.__id]=f,f.readyState=WebSocket.CONNECTING,f.bufferedAmount=0,f.__events={},b?typeof b=="string"&&(b=[b]):b=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(f.__id,a,b,c||null,d||0,e||null)})},0)},WebSocket.prototype.send=function(a){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var b=WebSocket.__flash.send(this.__id,encodeURIComponent(a));if(b<0)return!0;this.bufferedAmount+=b;return!1},WebSocket.prototype.close=function(){this.readyState!=WebSocket.CLOSED&&this.readyState!=WebSocket.CLOSING&&(this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id))},WebSocket.prototype.addEventListener=function(a,b,c){a in this.__events||(this.__events[a]=[]),this.__events[a].push(b)},WebSocket.prototype.removeEventListener=function(a,b,c){if(a in this.__events){var d=this.__events[a];for(var e=d.length-1;e>=0;--e)if(d[e]===b){d.splice(e,1);break}}},WebSocket.prototype.dispatchEvent=function(a){var b=this.__events[a.type]||[];for(var c=0;c"),this.doc.parentWindow.s=this,this.doc.close();var a=this.doc.createElement("div");a.className="socketio",this.doc.body.appendChild(a),this.iframe=this.doc.createElement("iframe"),a.appendChild(this.iframe),this.iframe.src=this.prepareUrl()+"/?t="+ +(new Date),this.onOpen()},c.prototype._=function(a,b){this.onData(a);var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,CollectGarbage()}},c.prototype.close=function(){this.destroy();return b.Transport.XHR.prototype.close.call(this)},c.check=function(){if("ActiveXObject"in window)try{var a=new ActiveXObject("htmlfile");return a&&b.Transport.XHR.check()}catch(c){}return!1},c.xdomainCheck=function(){return!1},b.transports.push("htmlfile")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(){b.Transport.XHR.apply(this,arguments),this.name="xhr-polling"}a["xhr-polling"]=c,b.util.inherit(c,b.Transport.XHR),c.prototype.open=function(){var a=this;b.util.defer(function(){b.Transport.XHR.prototype.open.call(a)});return!1},c.prototype.get=function(){function b(){this.readyState==4&&(this.onreadystatechange=this.onload=d,this.status==200?(a.onData(this.responseText),a.get()):a.onClose())}var a=this;this.xhr=this.request(),window.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=b,this.xhr.onerror=function(b){a.onError(b)}):this.xhr.onreadystatechange=b,this.xhr.send(null)},b.transports.push("xhr-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){if(!!a){b.Transport["xhr-polling"].apply(this,arguments),this.name="jsonp-polling",this.insertAt=document.getElementsByTagName("script")[0],this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}}a["jsonp-polling"]=c,b.util.inherit(c,b.Transport["xhr-polling"]),c.prototype.post=function(a){function h(){b.iframe&&b.form.removeChild(b.iframe);try{f=document.createElement('