PageRenderTime 998ms queryFilters 188ms Sphinxql 1327ms GetByIds 987ms meta 0ms repositoryFilters 45ms languageFilters 8ms sourceFilters 92ms

735,592 results for 'socket repo:dvv/wscomm' (998 ms)

Source

Language

Repository

Socket.hsc https://github.com/hf6440/network.git | Unknown | 1,674 lines
351    allocaBytes (2 * sizeOf (1 :: CInt)) $ \ fdArr -> do
352    c_stype <- packSocketTypeOrThrow "socketPair" stype
353    _rc <- throwSocketErrorIfMinus1Retry "socketpair" $
781
782socketPort :: Socket            -- Connected & Bound Socket
783           -> IO PortNumber     -- Port Number of Socket
822
823-- | Socket options for use with 'setSocketOption' and 'getSocketOption'.
824--
1172socketToHandle :: Socket -> IOMode -> IO Handle
1173socketToHandle s@(MkSocket fd _ _ _ socketStatus) mode = do
1174 modifyMVar socketStatus $ \ status ->
1645-- | Deprecated alias for 'bind'.
1646bindSocket :: Socket    -- Unconnected Socket
1647           -> SockAddr  -- Address to Bind to
Socket.java https://github.com/PAmoto/android_libcore.git | Java | 1,154 lines
328     */
329    protected Socket(SocketImpl impl) throws SocketException {
330        this.impl = impl;
783            if (!isConnected()) {
784                throw new SocketException("Socket is not connected");
785                // a connected socket must be created
1059    /**
1060     * Gets the setting of the socket option {@code SocketOptions.SO_OOBINLINE}.
1061     *
1073    /**
1074     * Sets the {@see SocketOptions#IP_TOS} value for every packet sent by this socket.
1075     *
1087    /**
1088     * Returns this socket's {@see SocketOptions#IP_TOS} setting.
1089     *
Socket.hsc https://github.com/singpolyma/network.git | Unknown | 1,671 lines
355    allocaBytes (2 * sizeOf (1 :: CInt)) $ \ fdArr -> do
356    c_stype <- packSocketTypeOrThrow "socketPair" stype
357    _rc <- throwSocketErrorIfMinus1Retry "socketpair" $
785
786socketPort :: Socket            -- Connected & Bound Socket
787           -> IO PortNumber     -- Port Number of Socket
826
827-- | Socket options for use with 'setSocketOption' and 'getSocketOption'.
828--
1176socketToHandle :: Socket -> IOMode -> IO Handle
1177socketToHandle s@(MkSocket fd _ _ _ socketStatus) mode = do
1178 modifyMVar socketStatus $ \ status ->
1642-- | Deprecated alias for 'bind'.
1643bindSocket :: Socket    -- Unconnected Socket
1644           -> SockAddr  -- Address to Bind to
socket.io.min.js https://github.com/ngokevin/underthegun.git | JavaScript | 1,151 lines
8    <meta http-equiv="X-UA-Compatible" content="IE=edge">
9        <title>socket.io-client/dist/socket.io.min.js at master · LearnBoost/socket.io-client · GitHub</title>
10    <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub" />
199                  <h4>
200                      <a href="/LearnBoost/socket.io-client/blob/webworker/dist/socket.io.min.js" class="js-navigation-open" data-name="webworker" rel="nofollow">webworker</a>
201                  </h4>
562      <div class="breadcrumb">
563        <span class='bold'><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/LearnBoost/socket.io-client" class="js-slide-to" data-direction="back" itemscope="url"><span itemprop="title">socket.io-client</span></a></span></span> / <span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/LearnBoost/socket.io-client/tree/master/dist" class="js-slide-to" data-direction="back" itemscope="url"><span itemprop="title">dist</span></a></span> / <strong class="final-path">socket.io.min.js</strong> <span class="js-clippy mini-icon mini-icon-clippy " data-clipboard-text="dist/socket.io.min.js" data-copied-hint="copied!" data-copy-hint="copy to clipboard"></span>
564      </div>
632    <div class="frames">
633      <div class="frame" data-permalink-url="/LearnBoost/socket.io-client/blob/63f18383647e83ea0fcab4fbac53c25ff95db508/dist/socket.io.min.js" data-title="socket.io-client/dist/socket.io.min.js at master · LearnBoost/socket.io-client · GitHub" data-type="blob">
634
662          <td width="100%">
663                <div class="highlight"><pre><div class='line' id='LC1'>/*! Socket.IO.min.js build:0.9.11, production. Copyright(c) 2011 LearnBoost &lt;dev@learnboost.com&gt; MIT Licensed */</div><div class='line' id='LC2'>var io=&quot;undefined&quot;==typeof module?{}:module.exports;(function(){(function(a,b){var c=a;c.version=&quot;0.9.11&quot;,c.protocol=1,c.transports=[],c.j=[],c.sockets={},c.connect=function(a,d){var e=c.util.parseUri(a),f,g;b&amp;&amp;b.location&amp;&amp;(e.protocol=e.protocol||b.location.protocol.slice(0,-1),e.host=e.host||(b.document?b.document.domain:b.location.hostname),e.port=e.port||b.location.port),f=c.util.uniqueUri(e);var h={host:e.host,secure:&quot;https&quot;==e.protocol,port:e.port||(&quot;https&quot;==e.protocol?443:80),query:e.query||&quot;&quot;};c.util.merge(h,d);if(h[&quot;force new connection&quot;]||!c.sockets[f])g=new c.Socket(h);return!h[&quot;force new connection&quot;]&amp;&amp;g&amp;&amp;(c.sockets[f]=g),g=g||c.sockets[f],g.of(e.path.length&gt;1?e.path:&quot;&quot;)}})(&quot;object&quot;==typeof module?module.exports:this.io={},this),function(a,b){var c=a.util={},d=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,e=[&quot;source&quot;,&quot;protocol&quot;,&quot;authority&quot;,&quot;userInfo&quot;,&quot;user&quot;,&quot;password&quot;,&quot;host&quot;,&quot;port&quot;,&quot;relative&quot;,&quot;path&quot;,&quot;directory&quot;,&quot;file&quot;,&quot;query&quot;,&quot;anchor&quot;];c.parseUri=function(a){var b=d.exec(a||&quot;&quot;),c={},f=14;while(f--)c[e[f]]=b[f]||&quot;&quot;;return c},c.uniqueUri=function(a){var c=a.protocol,d=a.host,e=a.port;return&quot;document&quot;in b?(d=d||document.domain,e=e||(c==&quot;https&quot;&amp;&amp;document.location.protocol!==&quot;https:&quot;?443:document.location.port)):(d=d||&quot;localhost&quot;,!e&amp;&amp;c==&quot;https&quot;&amp;&amp;(e=443)),(c||&quot;http&quot;)+&quot;://&quot;+d+&quot;:&quot;+(e||80)},c.query=function(a,b){var d=c.chunkQuery(a||&quot;&quot;),e=[];c.merge(d,c.chunkQuery(b||&quot;&quot;));for(var f in d)d.hasOwnProperty(f)&amp;&amp;e.push(f+&quot;=&quot;+d[f]);return e.length?&quot;?&quot;+e.join(&quot;&amp;&quot;):&quot;&quot;},c.chunkQuery=function(a){var b={},c=a.split(&quot;&amp;&quot;),d=0,e=c.length,f;for(;d&lt;e;++d)f=c[d].split(&quot;=&quot;),f[0]&amp;&amp;(b[f[0]]=f[1]);return b};var f=!1;c.load=function(a){if(&quot;document&quot;in b&amp;&amp;document.readyState===&quot;complete&quot;||f)return a();c.on(b,&quot;load&quot;,a,!1)},c.on=function(a,b,c,d){a.attachEvent?a.attachEvent(&quot;on&quot;+b,c):a.addEventListener&amp;&amp;a.addEventListener(b,c,d)},c.request=function(a){if(a&amp;&amp;&quot;undefined&quot;!=typeof XDomainRequest&amp;&amp;!c.ua.hasCORS)return new XDomainRequest;if(&quot;undefined&quot;!=typeof XMLHttpRequest&amp;&amp;(!a||c.ua.hasCORS))return new XMLHttpRequest;if(!a)try{return new(window[[&quot;Active&quot;].concat(&quot;Object&quot;).join(&quot;X&quot;)])(&quot;Microsoft.XMLHTTP&quot;)}catch(b){}return null},&quot;undefined&quot;!=typeof window&amp;&amp;c.load(function(){f=!0}),c.defer=function(a){if(!c.ua.webkit||&quot;undefined&quot;!=typeof importScripts)return a();c.load(function(){setTimeout(a,100)})},c.merge=function(b,d,e,f){var g=f||[],h=typeof e==&quot;undefined&quot;?2:e,i;for(i in d)d.hasOwnProperty(i)&amp;&amp;c.indexOf(g,i)&lt;0&amp;&amp;(typeof b[i]!=&quot;object&quot;||!h?(b[i]=d[i],g.push(d[i])):c.merge(b[i],d[i],h-1,g));return b},c.mixin=function(a,b){c.merge(a.prototype,b.prototype)},c.inherit=function(a,b){function c(){}c.prototype=b.prototype,a.prototype=new c},c.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)===&quot;[object Array]&quot;},c.intersect=function(a,b){var d=[],e=a.length&gt;b.length?a:b,f=a.length&gt;b.length?b:a;for(var g=0,h=f.length;g&lt;h;g++)~c.indexOf(e,f[g])&amp;&amp;d.push(f[g]);return d},c.indexOf=function(a,b,c){for(var d=a.length,c=c&lt;0?c+d&lt;0?0:c+d:c||0;c&lt;d&amp;&amp;a[c]!==b;c++);return d&lt;=c?-1:c},c.toArray=function(a){var b=[];for(var c=0,d=a.length;c&lt;d;c++)b.push(a[c]);return b},c.ua={},c.ua.hasCORS=&quot;undefined&quot;!=typeof XMLHttpRequest&amp;&amp;function(){try{var a=new XMLHttpRequest}catch(b){return!1}return a.withCredentials!=undefined}(),c.ua.webkit=&quot;undefined&quot;!=typeof navigator&amp;&amp;/webkit/i.test(navigator.userAgent),c.ua.iDevice=&quot;undefined&quot;!=typeof navigator&amp;&amp;/iPad|iPhone|iPod/i.test(navigator.userAgent)}(&quot;undefined&quot;!=typeof io?io:module.exports,this),function(a,b){function c(){}a.EventEmitter=c,c.prototype.on=function(a,c){return this.$events||(this.$events={}),this.$events[a]?b.util.isArray(this.$events[a])?this.$events[a].push(c):this.$events[a]=[this.$events[a],c]:this.$events[a]=c,this},c.prototype.addListener=c.prototype.on,c.prototype.once=function(a,b){function d(){c.removeListener(a,d),b.apply(this,arguments)}var c=this;return d.listener=b,this.on(a,d),this},c.prototype.removeListener=function(a,c){if(this.$events&amp;&amp;this.$events[a]){var d=this.$events[a];if(b.util.isArray(d)){var e=-1;for(var f=0,g=d.length;f&lt;g;f++)if(d[f]===c||d[f].listener&amp;&amp;d[f].listener===c){e=f;break}if(e&lt;0)return this;d.splice(e,1),d.length||delete this.$events[a]}else(d===c||d.listener&amp;&amp;d.listener===c)&amp;&amp;delete this.$events[a]}return this},c.prototype.removeAllListeners=function(a){return a===undefined?(this.$events={},this):(this.$events&amp;&amp;this.$events[a]&amp;&amp;(this.$events[a]=null),this)},c.prototype.listeners=function(a){return this.$events||(this.$events={}),this.$events[a]||(this.$events[a]=[]),b.util.isArray(this.$events[a])||(this.$events[a]=[this.$events[a]]),this.$events[a]},c.prototype.emit=function(a){if(!this.$events)return!1;var c=this.$events[a];if(!c)return!1;var d=Array.prototype.slice.call(arguments,1);if(&quot;function&quot;==typeof c)c.apply(this,d);else{if(!b.util.isArray(c))return!1;var e=c.slice();for(var f=0,g=e.length;f&lt;g;f++)e[f].apply(this,d)}return!0}}(&quot;undefined&quot;!=typeof io?io:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports),function(exports,nativeJSON){function f(a){return a&lt;10?&quot;0&quot;+a:a}function date(a,b){return isFinite(a.valueOf())?a.getUTCFullYear()+&quot;-&quot;+f(a.getUTCMonth()+1)+&quot;-&quot;+f(a.getUTCDate())+&quot;T&quot;+f(a.getUTCHours())+&quot;:&quot;+f(a.getUTCMinutes())+&quot;:&quot;+f(a.getUTCSeconds())+&quot;Z&quot;:null}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'&quot;'+a.replace(escapable,function(a){var b=meta[a];return typeof b==&quot;string&quot;?b:&quot;\\u&quot;+(&quot;0000&quot;+a.charCodeAt(0).toString(16)).slice(-4)})+'&quot;':'&quot;'+a+'&quot;'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i instanceof Date&amp;&amp;(i=date(a)),typeof rep==&quot;function&quot;&amp;&amp;(i=rep.call(b,a,i));switch(typeof i){case&quot;string&quot;:return quote(i);case&quot;number&quot;:return isFinite(i)?String(i):&quot;null&quot;;case&quot;boolean&quot;:case&quot;null&quot;:return String(i);case&quot;object&quot;:if(!i)return&quot;null&quot;;gap+=indent,h=[];if(Object.prototype.toString.apply(i)===&quot;[object Array]&quot;){f=i.length;for(c=0;c&lt;f;c+=1)h[c]=str(c,i)||&quot;null&quot;;return e=h.length===0?&quot;[]&quot;:gap?&quot;[\n&quot;+gap+h.join(&quot;,\n&quot;+gap)+&quot;\n&quot;+g+&quot;]&quot;:&quot;[&quot;+h.join(&quot;,&quot;)+&quot;]&quot;,gap=g,e}if(rep&amp;&amp;typeof rep==&quot;object&quot;){f=rep.length;for(c=0;c&lt;f;c+=1)typeof rep[c]==&quot;string&quot;&amp;&amp;(d=rep[c],e=str(d,i),e&amp;&amp;h.push(quote(d)+(gap?&quot;: &quot;:&quot;:&quot;)+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&amp;&amp;(e=str(d,i),e&amp;&amp;h.push(quote(d)+(gap?&quot;: &quot;:&quot;:&quot;)+e));return e=h.length===0?&quot;{}&quot;:gap?&quot;{\n&quot;+gap+h.join(&quot;,\n&quot;+gap)+&quot;\n&quot;+g+&quot;}&quot;:&quot;{&quot;+h.join(&quot;,&quot;)+&quot;}&quot;,gap=g,e}}&quot;use strict&quot;;if(nativeJSON&amp;&amp;nativeJSON.parse)return exports.JSON={parse:nativeJSON.parse,stringify:nativeJSON.stringify};var JSON=exports.JSON={},cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\&quot;\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={&quot;\b&quot;:&quot;\\b&quot;,&quot;\t&quot;:&quot;\\t&quot;,&quot;\n&quot;:&quot;\\n&quot;,&quot;\f&quot;:&quot;\\f&quot;,&quot;\r&quot;:&quot;\\r&quot;,'&quot;':'\\&quot;',&quot;\\&quot;:&quot;\\\\&quot;},rep;JSON.stringify=function(a,b,c){var d;gap=&quot;&quot;,indent=&quot;&quot;;if(typeof c==&quot;number&quot;)for(d=0;d&lt;c;d+=1)indent+=&quot; &quot;;else typeof c==&quot;string&quot;&amp;&amp;(indent=c);rep=b;if(!b||typeof b==&quot;function&quot;||typeof b==&quot;object&quot;&amp;&amp;typeof b.length==&quot;number&quot;)return str(&quot;&quot;,{&quot;&quot;:a});throw new Error(&quot;JSON.stringify&quot;)},JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&amp;&amp;typeof e==&quot;object&quot;)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&amp;&amp;(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&amp;&amp;(text=text.replace(cx,function(a){return&quot;\\u&quot;+(&quot;0000&quot;+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:[&quot;\\\/bfnrt]|u[0-9a-fA-F]{4})/g,&quot;@&quot;).replace(/&quot;[^&quot;\\\n\r]*&quot;|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,&quot;]&quot;).replace(/(?:^|:|,)(?:\s*\[)+/g,&quot;&quot;)))return j=eval(&quot;(&quot;+text+&quot;)&quot;),typeof reviver==&quot;function&quot;?walk({&quot;&quot;:j},&quot;&quot;):j;throw new SyntaxError(&quot;JSON.parse&quot;)}}(&quot;undefined&quot;!=typeof io?io:module.exports,typeof JSON!=&quot;undefined&quot;?JSON:undefined),function(a,b){var c=a.parser={},d=c.packets=[&quot;disconnect&quot;,&quot;connect&quot;,&quot;heartbeat&quot;,&quot;message&quot;,&quot;json&quot;,&quot;event&quot;,&quot;ack&quot;,&quot;error&quot;,&quot;noop&quot;],e=c.reasons=[&quot;transport not supported&quot;,&quot;client not handshaken&quot;,&quot;unauthorized&quot;],f=c.advice=[&quot;reconnect&quot;],g=b.JSON,h=b.util.indexOf;c.encodePacket=function(a){var b=h(d,a.type),c=a.id||&quot;&quot;,i=a.endpoint||&quot;&quot;,j=a.ack,k=null;switch(a.type){case&quot;error&quot;:var l=a.reason?h(e,a.reason):&quot;&quot;,m=a.advice?h(f,a.advice):&quot;&quot;;if(l!==&quot;&quot;||m!==&quot;&quot;)k=l+(m!==&quot;&quot;?&quot;+&quot;+m:&quot;&quot;);break;case&quot;message&quot;:a.data!==&quot;&quot;&amp;&amp;(k=a.data);break;case&quot;event&quot;:var n={name:a.name};a.args&amp;&amp;a.args.length&amp;&amp;(n.args=a.args),k=g.stringify(n);break;case&quot;json&quot;:k=g.stringify(a.data);break;case&quot;connect&quot;:a.qs&amp;&amp;(k=a.qs);break;case&quot;ack&quot;:k=a.ackId+(a.args&amp;&amp;a.args.length?&quot;+&quot;+g.stringify(a.args):&quot;&quot;)}var o=[b,c+(j==&quot;data&quot;?&quot;+&quot;:&quot;&quot;),i];return k!==null&amp;&amp;k!==undefined&amp;&amp;o.push(k),o.join(&quot;:&quot;)},c.encodePayload=function(a){var b=&quot;&quot;;if(a.length==1)return a[0];for(var c=0,d=a.length;c&lt;d;c++){var e=a[c];b+=&quot;\ufffd&quot;+e.length+&quot;\ufffd&quot;+a[c]}return b};var i=/([^:]+):([0-9]+)?(\+)?:([^:]+)?:?([\s\S]*)?/;c.decodePacket=function(a){var b=a.match(i);if(!b)return{};var c=b[2]||&quot;&quot;,a=b[5]||&quot;&quot;,h={type:d[b[1]],endpoint:b[4]||&quot;&quot;};c&amp;&amp;(h.id=c,b[3]?h.ack=&quot;data&quot;:h.ack=!0);switch(h.type){case&quot;error&quot;:var b=a.split(&quot;+&quot;);h.reason=e[b[0]]||&quot;&quot;,h.advice=f[b[1]]||&quot;&quot;;break;case&quot;message&quot;:h.data=a||&quot;&quot;;break;case&quot;event&quot;:try{var j=g.parse(a);h.name=j.name,h.args=j.args}catch(k){}h.args=h.args||[];break;case&quot;json&quot;:try{h.data=g.parse(a)}catch(k){}break;case&quot;connect&quot;:h.qs=a||&quot;&quot;;break;case&quot;ack&quot;:var b=a.match(/^([0-9]+)(\+)?(.*)/);if(b){h.ackId=b[1],h.args=[];if(b[3])try{h.args=b[3]?g.parse(b[3]):[]}catch(k){}}break;case&quot;disconnect&quot;:case&quot;heartbeat&quot;:}return h},c.decodePayload=function(a){if(a.charAt(0)==&quot;\ufffd&quot;){var b=[];for(var d=1,e=&quot;&quot;;d&lt;a.length;d++)a.charAt(d)==&quot;\ufffd&quot;?(b.push(c.decodePacket(a.substr(d+1).substr(0,e))),d+=Number(e)+1,e=&quot;&quot;):e+=a.charAt(d);return b}return[c.decodePacket(a)]}}(&quot;undefined&quot;!=typeof io?io:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports),function(a,b){function c(a,b){this.socket=a,this.sessid=b}a.Transport=c,b.util.mixin(c,b.EventEmitter),c.prototype.heartbeats=function(){return!0},c.prototype.onData=function(a){this.clearCloseTimeout(),(this.socket.connected||this.socket.connecting||this.socket.reconnecting)&amp;&amp;this.setCloseTimeout();if(a!==&quot;&quot;){var c=b.parser.decodePayload(a);if(c&amp;&amp;c.length)for(var d=0,e=c.length;d&lt;e;d++)this.onPacket(c[d])}return this},c.prototype.onPacket=function(a){return this.socket.setHeartbeatTimeout(),a.type==&quot;heartbeat&quot;?this.onHeartbeat():(a.type==&quot;connect&quot;&amp;&amp;a.endpoint==&quot;&quot;&amp;&amp;this.onConnect(),a.type==&quot;error&quot;&amp;&amp;a.advice==&quot;reconnect&quot;&amp;&amp;(this.isOpen=!1),this.socket.onPacket(a),this)},c.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var a=this;this.closeTimeout=setTimeout(function(){a.onDisconnect()},this.socket.closeTimeout)}},c.prototype.onDisconnect=function(){return this.isOpen&amp;&amp;this.close(),this.clearTimeouts(),this.socket.onDisconnect(),this},c.prototype.onConnect=function(){return this.socket.onConnect(),this},c.prototype.clearCloseTimeout=function(){this.closeTimeout&amp;&amp;(clearTimeout(this.closeTimeout),this.closeTimeout=null)},c.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&amp;&amp;clearTimeout(this.reopenTimeout)},c.prototype.packet=function(a){this.send(b.parser.encodePacket(a))},c.prototype.onHeartbeat=function(a){this.packet({type:&quot;heartbeat&quot;})},c.prototype.onOpen=function(){this.isOpen=!0,this.clearCloseTimeout(),this.socket.onOpen()},c.prototype.onClose=function(){var a=this;this.isOpen=!1,this.socket.onClose(),this.onDisconnect()},c.prototype.prepareUrl=function(){var a=this.socket.options;return this.scheme()+&quot;://&quot;+a.host+&quot;:&quot;+a.port+&quot;/&quot;+a.resource+&quot;/&quot;+b.protocol+&quot;/&quot;+this.name+&quot;/&quot;+this.sessid},c.prototype.ready=function(a,b){b.call(this)}}(&quot;undefined&quot;!=typeof io?io:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports),function(a,b,c){function d(a){this.options={port:80,secure:!1,document:&quot;document&quot;in c?document:!1,resource:&quot;socket.io&quot;,transports:b.transports,&quot;connect timeout&quot;:1e4,&quot;try multiple transports&quot;:!0,reconnect:!0,&quot;reconnection delay&quot;:500,&quot;reconnection limit&quot;:Infinity,&quot;reopen delay&quot;:3e3,&quot;max reconnection attempts&quot;:10,&quot;sync disconnect on unload&quot;:!1,&quot;auto connect&quot;:!0,&quot;flash policy port&quot;:10843,manualFlush:!1},b.util.merge(this.options,a),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1,this.namespaces={},this.buffer=[],this.doBuffer=!1;if(this.options[&quot;sync disconnect on unload&quot;]&amp;&amp;(!this.isXDomain()||b.util.ua.hasCORS)){var d=this;b.util.on(c,&quot;beforeunload&quot;,function(){d.disconnectSync()},!1)}this.options[&quot;auto connect&quot;]&amp;&amp;this.connect()}function e(){}a.Socket=d,b.util.mixin(d,b.EventEmitter),d.prototype.of=function(a){return this.namespaces[a]||(this.namespaces[a]=new b.SocketNamespace(this,a),a!==&quot;&quot;&amp;&amp;this.namespaces[a].packet({type:&quot;connect&quot;})),this.namespaces[a]},d.prototype.publish=function(){this.emit.apply(this,arguments);var a;for(var b in this.namespaces)this.namespaces.hasOwnProperty(b)&amp;&amp;(a=this.of(b),a.$emit.apply(a,arguments))},d.prototype.handshake=function(a){function f(b){b instanceof Error?(c.connecting=!1,c.onError(b.message)):a.apply(null,b.split(&quot;:&quot;))}var c=this,d=this.options,g=[&quot;http&quot;+(d.secure?&quot;s&quot;:&quot;&quot;)+&quot;:/&quot;,d.host+&quot;:&quot;+d.port,d.resource,b.protocol,b.util.query(this.options.query,&quot;t=&quot;+ +(new Date))].join(&quot;/&quot;);if(this.isXDomain()&amp;&amp;!b.util.ua.hasCORS){var h=document.getElementsByTagName(&quot;script&quot;)[0],i=document.createElement(&quot;script&quot;);i.src=g+&quot;&amp;jsonp=&quot;+b.j.length,h.parentNode.insertBefore(i,h),b.j.push(function(a){f(a),i.parentNode.removeChild(i)})}else{var j=b.util.request();j.open(&quot;GET&quot;,g,!0),this.isXDomain()&amp;&amp;(j.withCredentials=!0),j.onreadystatechange=function(){j.readyState==4&amp;&amp;(j.onreadystatechange=e,j.status==200?f(j.responseText):j.status==403?c.onError(j.responseText):(c.connecting=!1,!c.reconnecting&amp;&amp;c.onError(j.responseText)))},j.send(null)}},d.prototype.getTransport=function(a){var c=a||this.transports,d;for(var e=0,f;f=c[e];e++)if(b.Transport[f]&amp;&amp;b.Transport[f].check(this)&amp;&amp;(!this.isXDomain()||b.Transport[f].xdomainCheck(this)))return new b.Transport[f](this,this.sessionid);return null},d.prototype.connect=function(a){if(this.connecting)return this;var c=this;return c.connecting=!0,this.handshake(function(d,e,f,g){function h(a){c.transport&amp;&amp;c.transport.clearTimeouts(),c.transport=c.getTransport(a);if(!c.transport)return c.publish(&quot;connect_failed&quot;);c.transport.ready(c,function(){c.connecting=!0,c.publish(&quot;connecting&quot;,c.transport.name),c.transport.open(),c.options[&quot;connect timeout&quot;]&amp;&amp;(c.connectTimeoutTimer=setTimeout(function(){if(!c.connected){c.connecting=!1;if(c.options[&quot;try multiple transports&quot;]){var a=c.transports;while(a.length&gt;0&amp;&amp;a.splice(0,1)[0]!=c.transport.name);a.length?h(a):c.publish(&quot;connect_failed&quot;)}}},c.options[&quot;connect timeout&quot;]))})}c.sessionid=d,c.closeTimeout=f*1e3,c.heartbeatTimeout=e*1e3,c.transports||(c.transports=c.origTransports=g?b.util.intersect(g.split(&quot;,&quot;),c.options.transports):c.options.transports),c.setHeartbeatTimeout(),h(c.transports),c.once(&quot;connect&quot;,function(){clearTimeout(c.connectTimeoutTimer),a&amp;&amp;typeof a==&quot;function&quot;&amp;&amp;a()})}),this},d.prototype.setHeartbeatTimeout=function(){clearTimeout(this.heartbeatTimeoutTimer);if(this.transport&amp;&amp;!this.transport.heartbeats())return;var a=this;this.heartbeatTimeoutTimer=setTimeout(function(){a.transport.onClose()},this.heartbeatTimeout)},d.prototype.packet=function(a){return this.connected&amp;&amp;!this.doBuffer?this.transport.packet(a):this.buffer.push(a),this},d.prototype.setBuffer=function(a){this.doBuffer=a,!a&amp;&amp;this.connected&amp;&amp;this.buffer.length&amp;&amp;(this.options.manualFlush||this.flushBuffer())},d.prototype.flushBuffer=function(){this.transport.payload(this.buffer),this.buffer=[]},d.prototype.disconnect=function(){if(this.connected||this.connecting)this.open&amp;&amp;this.of(&quot;&quot;).packet({type:&quot;disconnect&quot;}),this.onDisconnect(&quot;booted&quot;);return this},d.prototype.disconnectSync=function(){var a=b.util.request(),c=[&quot;http&quot;+(this.options.secure?&quot;s&quot;:&quot;&quot;)+&quot;:/&quot;,this.options.host+&quot;:&quot;+this.options.port,this.options.resource,b.protocol,&quot;&quot;,this.sessionid].join(&quot;/&quot;)+&quot;/?disconnect=1&quot;;a.open(&quot;GET&quot;,c,!1),a.send(null),this.onDisconnect(&quot;booted&quot;)},d.prototype.isXDomain=function(){var a=c.location.port||(&quot;https:&quot;==c.location.protocol?443:80);return this.options.host!==c.location.hostname||this.options.port!=a},d.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit(&quot;connect&quot;))},d.prototype.onOpen=function(){this.open=!0},d.prototype.onClose=function(){this.open=!1,clearTimeout(this.heartbeatTimeoutTimer)},d.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)},d.prototype.onError=function(a){a&amp;&amp;a.advice&amp;&amp;a.advice===&quot;reconnect&quot;&amp;&amp;(this.connected||this.connecting)&amp;&amp;(this.disconnect(),this.options.reconnect&amp;&amp;this.reconnect()),this.publish(&quot;error&quot;,a&amp;&amp;a.reason?a.reason:a)},d.prototype.onDisconnect=function(a){var b=this.connected,c=this.connecting;this.connected=!1,this.connecting=!1,this.open=!1;if(b||c)this.transport.close(),this.transport.clearTimeouts(),b&amp;&amp;(this.publish(&quot;disconnect&quot;,a),&quot;booted&quot;!=a&amp;&amp;this.options.reconnect&amp;&amp;!this.reconnecting&amp;&amp;this.reconnect())},d.prototype.reconnect=function(){function e(){if(a.connected){for(var b in a.namespaces)a.namespaces.hasOwnProperty(b)&amp;&amp;&quot;&quot;!==b&amp;&amp;a.namespaces[b].packet({type:&quot;connect&quot;});a.publish(&quot;reconnect&quot;,a.transport.name,a.reconnectionAttempts)}clearTimeout(a.reconnectionTimer),a.removeListener(&quot;connect_failed&quot;,f),a.removeListener(&quot;connect&quot;,f),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options[&quot;try multiple transports&quot;]=c}function f(){if(!a.reconnecting)return;if(a.connected)return e();if(a.connecting&amp;&amp;a.reconnecting)return a.reconnectionTimer=setTimeout(f,1e3);a.reconnectionAttempts++&gt;=b?a.redoTransports?(a.publish(&quot;reconnect_failed&quot;),e()):(a.on(&quot;connect_failed&quot;,f),a.options[&quot;try multiple transports&quot;]=!0,a.transports=a.origTransports,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay&lt;d&amp;&amp;(a.reconnectionDelay*=2),a.connect(),a.publish(&quot;reconnecting&quot;,a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(f,a.reconnectionDelay))}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options[&quot;reconnection delay&quot;];var a=this,b=this.options[&quot;max reconnection attempts&quot;],c=this.options[&quot;try multiple transports&quot;],d=this.options[&quot;reconnection limit&quot;];this.options[&quot;try multiple transports&quot;]=!1,this.reconnectionTimer=setTimeout(f,this.reconnectionDelay),this.on(&quot;connect&quot;,f)}}(&quot;undefined&quot;!=typeof io?io:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports,this),function(a,b){function c(a,b){this.socket=a,this.name=b||&quot;&quot;,this.flags={},this.json=new d(this,&quot;json&quot;),this.ackPackets=0,this.acks={}}function d(a,b){this.namespace=a,this.name=b}a.SocketNamespace=c,b.util.mixin(c,b.EventEmitter),c.prototype.$emit=b.EventEmitter.prototype.emit,c.prototype.of=function(){return this.socket.of.apply(this.socket,arguments)},c.prototype.packet=function(a){return a.endpoint=this.name,this.socket.packet(a),this.flags={},this},c.prototype.send=function(a,b){var c={type:this.flags.json?&quot;json&quot;:&quot;message&quot;,data:a};return&quot;function&quot;==typeof b&amp;&amp;(c.id=++this.ackPackets,c.ack=!0,this.acks[c.id]=b),this.packet(c)},c.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:&quot;event&quot;,name:a};return&quot;function&quot;==typeof c&amp;&amp;(d.id=++this.ackPackets,d.ack=&quot;data&quot;,this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b,this.packet(d)},c.prototype.disconnect=function(){return this.name===&quot;&quot;?this.socket.disconnect():(this.packet({type:&quot;disconnect&quot;}),this.$emit(&quot;disconnect&quot;)),this},c.prototype.onPacket=function(a){function d(){c.packet({type:&quot;ack&quot;,args:b.util.toArray(arguments),ackId:a.id})}var c=this;switch(a.type){case&quot;connect&quot;:this.$emit(&quot;connect&quot;);break;case&quot;disconnect&quot;:this.name===&quot;&quot;?this.socket.onDisconnect(a.reason||&quot;booted&quot;):this.$emit(&quot;disconnect&quot;,a.reason);break;case&quot;message&quot;:case&quot;json&quot;:var e=[&quot;message&quot;,a.data];a.ack==&quot;data&quot;?e.push(d):a.ack&amp;&amp;this.packet({type:&quot;ack&quot;,ackId:a.id}),this.$emit.apply(this,e);break;case&quot;event&quot;:var e=[a.name].concat(a.args);a.ack==&quot;data&quot;&amp;&amp;e.push(d),this.$emit.apply(this,e);break;case&quot;ack&quot;:this.acks[a.ackId]&amp;&amp;(this.acks[a.ackId].apply(this,a.args),delete this.acks[a.ackId]);break;case&quot;error&quot;:a.advice?this.socket.onError(a):a.reason==&quot;unauthorized&quot;?this.$emit(&quot;connect_failed&quot;,a.reason):this.$emit(&quot;error&quot;,a.reason)}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this.namespace,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this.namespace,arguments)}}(&quot;undefined&quot;!=typeof io?io:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports),function(a,b,c){function d(a){b.Transport.apply(this,arguments)}a.websocket=d,b.util.inherit(d,b.Transport),d.prototype.name=&quot;websocket&quot;,d.prototype.open=function(){var a=b.util.query(this.socket.options.query),d=this,e;return e||(e=c.MozWebSocket||c.WebSocket),this.websocket=new e(this.prepareUrl()+a),this.websocket.onopen=function(){d.onOpen(),d.socket.setBuffer(!1)},this.websocket.onmessage=function(a){d.onData(a.data)},this.websocket.onclose=function(){d.onClose(),d.socket.setBuffer(!0)},this.websocket.onerror=function(a){d.onError(a)},this},b.util.ua.iDevice?d.prototype.send=function(a){var b=this;return setTimeout(function(){b.websocket.send(a)},0),this}:d.prototype.send=function(a){return this.websocket.send(a),this},d.prototype.payload=function(a){for(var b=0,c=a.length;b&lt;c;b++)this.packet(a[b]);return this},d.prototype.close=function(){return this.websocket.close(),this},d.prototype.onError=function(a){this.socket.onError(a)},d.prototype.scheme=function(){return this.socket.options.secure?&quot;wss&quot;:&quot;ws&quot;},d.check=function(){return&quot;WebSocket&quot;in c&amp;&amp;!(&quot;__addTask&quot;in WebSocket)||&quot;MozWebSocket&quot;in c},d.xdomainCheck=function(){return!0},b.transports.push(&quot;websocket&quot;)}(&quot;undefined&quot;!=typeof io?io.Transport:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports,this),function(a,b){function c(){b.Transport.websocket.apply(this,arguments)}a.flashsocket=c,b.util.inherit(c,b.Transport.websocket),c.prototype.name=&quot;flashsocket&quot;,c.prototype.open=function(){var a=this,c=arguments;return WebSocket.__addTask(function(){b.Transport.websocket.prototype.open.apply(a,c)}),this},c.prototype.send=function(){var a=this,c=arguments;return WebSocket.__addTask(function(){b.Transport.websocket.prototype.send.apply(a,c)}),this},c.prototype.close=function(){return WebSocket.__tasks.length=0,b.Transport.websocket.prototype.close.call(this),this},c.prototype.ready=function(a,d){function e(){var b=a.options,e=b[&quot;flash policy port&quot;],g=[&quot;http&quot;+(b.secure?&quot;s&quot;:&quot;&quot;)+&quot;:/&quot;,b.host+&quot;:&quot;+b.port,b.resource,&quot;static/flashsocket&quot;,&quot;WebSocketMain&quot;+(a.isXDomain()?&quot;Insecure&quot;:&quot;&quot;)+&quot;.swf&quot;];c.loaded||(typeof WEB_SOCKET_SWF_LOCATION==&quot;undefined&quot;&amp;&amp;(WEB_SOCKET_SWF_LOCATION=g.join(&quot;/&quot;)),e!==843&amp;&amp;WebSocket.loadFlashPolicyFile(&quot;xmlsocket://&quot;+b.host+&quot;:&quot;+e),WebSocket.__initialize(),c.loaded=!0),d.call(f)}var f=this;if(document.body)return e();b.util.load(e)},c.check=function(){return typeof WebSocket!=&quot;undefined&quot;&amp;&amp;&quot;__initialize&quot;in WebSocket&amp;&amp;!!swfobject?swfobject.getFlashPlayerVersion().major&gt;=10:!1},c.xdomainCheck=function(){return!0},typeof window!=&quot;undefined&quot;&amp;&amp;(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),b.transports.push(&quot;flashsocket&quot;)}(&quot;undefined&quot;!=typeof io?io.Transport:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports);if(&quot;undefined&quot;!=typeof window)var swfobject=function(){function A(){if(t)return;try{var a=i.getElementsByTagName(&quot;body&quot;)[0].appendChild(Q(&quot;span&quot;));a.parentNode.removeChild(a)}catch(b){return}t=!0;var c=l.length;for(var d=0;d&lt;c;d++)l[d]()}function B(a){t?a():l[l.length]=a}function C(b){if(typeof h.addEventListener!=a)h.addEventListener(&quot;load&quot;,b,!1);else if(typeof i.addEventListener!=a)i.addEventListener(&quot;load&quot;,b,!1);else if(typeof h.attachEvent!=a)R(h,&quot;onload&quot;,b);else if(typeof h.onload==&quot;function&quot;){var c=h.onload;h.onload=function(){c(),b()}}else h.onload=b}function D(){k?E():F()}function E(){var c=i.getElementsByTagName(&quot;body&quot;)[0],d=Q(b);d.setAttribute(&quot;type&quot;,e);var f=c.appendChild(d);if(f){var g=0;(function(){if(typeof f.GetVariable!=a){var b=f.GetVariable(&quot;$version&quot;);b&amp;&amp;(b=b.split(&quot; &quot;)[1].split(&quot;,&quot;),y.pv=[parseInt(b[0],10),parseInt(b[1],10),parseInt(b[2],10)])}else if(g&lt;10){g++,setTimeout(arguments.callee,10);return}c.removeChild(d),f=null,F()})()}else F()}function F(){var b=m.length;if(b&gt;0)for(var c=0;c&lt;b;c++){var d=m[c].id,e=m[c].callbackFn,f={success:!1,id:d};if(y.pv[0]&gt;0){var g=P(d);if(g)if(S(m[c].swfVersion)&amp;&amp;!(y.wk&amp;&amp;y.wk&lt;312))U(d,!0),e&amp;&amp;(f.success=!0,f.ref=G(d),e(f));else if(m[c].expressInstall&amp;&amp;H()){var h={};h.data=m[c].expressInstall,h.width=g.getAttribute(&quot;width&quot;)||&quot;0&quot;,h.height=g.getAttribute(&quot;height&quot;)||&quot;0&quot;,g.getAttribute(&quot;class&quot;)&amp;&amp;(h.styleclass=g.getAttribute(&quot;class&quot;)),g.getAttribute(&quot;align&quot;)&amp;&amp;(h.align=g.getAttribute(&quot;align&quot;));var i={},j=g.getElementsByTagName(&quot;param&quot;),k=j.length;for(var l=0;l&lt;k;l++)j[l].getAttribute(&quot;name&quot;).toLowerCase()!=&quot;movie&quot;&amp;&amp;(i[j[l].getAttribute(&quot;name&quot;)]=j[l].getAttribute(&quot;value&quot;));I(h,i,d,e)}else J(g),e&amp;&amp;e(f)}else{U(d,!0);if(e){var n=G(d);n&amp;&amp;typeof n.SetVariable!=a&amp;&amp;(f.success=!0,f.ref=n),e(f)}}}}function G(c){var d=null,e=P(c);if(e&amp;&amp;e.nodeName==&quot;OBJECT&quot;)if(typeof e.SetVariable!=a)d=e;else{var f=e.getElementsByTagName(b)[0];f&amp;&amp;(d=f)}return d}function H(){return!u&amp;&amp;S(&quot;6.0.65&quot;)&amp;&amp;(y.win||y.mac)&amp;&amp;!(y.wk&amp;&amp;y.wk&lt;312)}function I(b,c,d,e){u=!0,r=e||null,s={success:!1,id:d};var g=P(d);if(g){g.nodeName==&quot;OBJECT&quot;?(p=K(g),q=null):(p=g,q=d),b.id=f;if(typeof b.width==a||!/%$/.test(b.width)&amp;&amp;parseInt(b.width,10)&lt;310)b.width=&quot;310&quot;;if(typeof b.height==a||!/%$/.test(b.height)&amp;&amp;parseInt(b.height,10)&lt;137)b.height=&quot;137&quot;;i.title=i.title.slice(0,47)+&quot; - Flash Player Installation&quot;;var j=y.ie&amp;&amp;y.win?[&quot;Active&quot;].concat(&quot;&quot;).join(&quot;X&quot;):&quot;PlugIn&quot;,k=&quot;MMredirectURL=&quot;+h.location.toString().replace(/&amp;/g,&quot;%26&quot;)+&quot;&amp;MMplayerType=&quot;+j+&quot;&amp;MMdoctitle=&quot;+i.title;typeof c.flashvars!=a?c.flashvars+=&quot;&amp;&quot;+k:c.flashvars=k;if(y.ie&amp;&amp;y.win&amp;&amp;g.readyState!=4){var l=Q(&quot;div&quot;);d+=&quot;SWFObjectNew&quot;,l.setAttribute(&quot;id&quot;,d),g.parentNode.insertBefore(l,g),g.style.display=&quot;none&quot;,function(){g.readyState==4?g.parentNode.removeChild(g):setTimeout(arguments.callee,10)}()}L(b,c,d)}}function J(a){if(y.ie&amp;&amp;y.win&amp;&amp;a.readyState!=4){var b=Q(&quot;div&quot;);a.parentNode.insertBefore(b,a),b.parentNode.replaceChild(K(a),b),a.style.display=&quot;none&quot;,function(){a.readyState==4?a.parentNode.removeChild(a):setTimeout(arguments.callee,10)}()}else a.parentNode.replaceChild(K(a),a)}function K(a){var c=Q(&quot;div&quot;);if(y.win&amp;&amp;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;g&lt;f;g++)(e[g].nodeType!=1||e[g].nodeName!=&quot;PARAM&quot;)&amp;&amp;e[g].nodeType!=8&amp;&amp;c.appendChild(e[g].cloneNode(!0))}}}return c}function L(c,d,f){var g,h=P(f);if(y.wk&amp;&amp;y.wk&lt;312)return g;if(h){typeof c.id==a&amp;&amp;(c.id=f);if(y.ie&amp;&amp;y.win){var i=&quot;&quot;;for(var j in c)c[j]!=Object.prototype[j]&amp;&amp;(j.toLowerCase()==&quot;data&quot;?d.movie=c[j]:j.toLowerCase()==&quot;styleclass&quot;?i+=' class=&quot;'+c[j]+'&quot;':j.toLowerCase()!=&quot;classid&quot;&amp;&amp;(i+=&quot; &quot;+j+'=&quot;'+c[j]+'&quot;'));var k=&quot;&quot;;for(var l in d)d[l]!=Object.prototype[l]&amp;&amp;(k+='&lt;param name=&quot;'+l+'&quot; value=&quot;'+d[l]+'&quot; /&gt;');h.outerHTML='&lt;object classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;'+i+&quot;&gt;&quot;+k+&quot;&lt;/object&gt;&quot;,n[n.length]=c.id,g=P(c.id)}else{var m=Q(b);m.setAttribute(&quot;type&quot;,e);for(var o in c)c[o]!=Object.prototype[o]&amp;&amp;(o.toLowerCase()==&quot;styleclass&quot;?m.setAttribute(&quot;class&quot;,c[o]):o.toLowerCase()!=&quot;classid&quot;&amp;&amp;m.setAttribute(o,c[o]));for(var p in d)d[p]!=Object.prototype[p]&amp;&amp;p.toLowerCase()!=&quot;movie&quot;&amp;&amp;M(m,p,d[p]);h.parentNode.replaceChild(m,h),g=m}}return g}function M(a,b,c){var d=Q(&quot;param&quot;);d.setAttribute(&quot;name&quot;,b),d.setAttribute(&quot;value&quot;,c),a.appendChild(d)}function N(a){var b=P(a);b&amp;&amp;b.nodeName==&quot;OBJECT&quot;&amp;&amp;(y.ie&amp;&amp;y.win?(b.style.display=&quot;none&quot;,function(){b.readyState==4?O(a):setTimeout(arguments.callee,10)}()):b.parentNode.removeChild(b))}function O(a){var b=P(a);if(b){for(var c in b)typeof b[c]==&quot;function&quot;&amp;&amp;(b[c]=null);b.parentNode.removeChild(b)}}function P(a){var b=null;try{b=i.getElementById(a)}catch(c){}return b}function Q(a){return i.createElement(a)}function R(a,b,c){a.attachEvent(b,c),o[o.length]=[a,b,c]}function S(a){var b=y.pv,c=a.split(&quot;.&quot;);return c[0]=parseInt(c[0],10),c[1]=parseInt(c[1],10)||0,c[2]=parseInt(c[2],10)||0,b[0]&gt;c[0]||b[0]==c[0]&amp;&amp;b[1]&gt;c[1]||b[0]==c[0]&amp;&amp;b[1]==c[1]&amp;&amp;b[2]&gt;=c[2]?!0:!1}function T(c,d,e,f){if(y.ie&amp;&amp;y.mac)return;var g=i.getElementsByTagName(&quot;head&quot;)[0];if(!g)return;var h=e&amp;&amp;typeof e==&quot;string&quot;?e:&quot;screen&quot;;f&amp;&amp;(v=null,w=null);if(!v||w!=h){var j=Q(&quot;style&quot;);j.setAttribute(&quot;type&quot;,&quot;text/css&quot;),j.setAttribute(&quot;media&quot;,h),v=g.appendChild(j),y.ie&amp;&amp;y.win&amp;&amp;typeof i.styleSheets!=a&amp;&amp;i.styleSheets.length&gt;0&amp;&amp;(v=i.styleSheets[i.styleSheets.length-1]),w=h}y.ie&amp;&amp;y.win?v&amp;&amp;typeof v.addRule==b&amp;&amp;v.addRule(c,d):v&amp;&amp;typeof i.createTextNode!=a&amp;&amp;v.appendChild(i.createTextNode(c+&quot; {&quot;+d+&quot;}&quot;))}function U(a,b){if(!x)return;var c=b?&quot;visible&quot;:&quot;hidden&quot;;t&amp;&amp;P(a)?P(a).style.visibility=c:T(&quot;#&quot;+a,&quot;visibility:&quot;+c)}function V(b){var c=/[\\\&quot;&lt;&gt;\.;]/,d=c.exec(b)!=null;return d&amp;&amp;typeof encodeURIComponent!=a?encodeURIComponent(b):b}var a=&quot;undefined&quot;,b=&quot;object&quot;,c=&quot;Shockwave Flash&quot;,d=&quot;ShockwaveFlash.ShockwaveFlash&quot;,e=&quot;application/x-shockwave-flash&quot;,f=&quot;SWFObjectExprInst&quot;,g=&quot;onreadystatechange&quot;,h=window,i=document,j=navigator,k=!1,l=[D],m=[],n=[],o=[],p,q,r,s,t=!1,u=!1,v,w,x=!0,y=function(){var f=typeof i.getElementById!=a&amp;&amp;typeof i.getElementsByTagName!=a&amp;&amp;typeof i.createElement!=a,g=j.userAgent.toLowerCase(),l=j.platform.toLowerCase(),m=l?/win/.test(l):/win/.test(g),n=l?/mac/.test(l):/mac/.test(g),o=/webkit/.test(g)?parseFloat(g.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,&quot;$1&quot;)):!1,p=!1,q=[0,0,0],r=null;if(typeof j.plugins!=a&amp;&amp;typeof j.plugins[c]==b)r=j.plugins[c].description,r&amp;&amp;(typeof j.mimeTypes==a||!j.mimeTypes[e]||!!j.mimeTypes[e].enabledPlugin)&amp;&amp;(k=!0,p=!1,r=r.replace(/^.*\s+(\S+\s+\S+$)/,&quot;$1&quot;),q[0]=parseInt(r.replace(/^(.*)\..*$/,&quot;$1&quot;),10),q[1]=parseInt(r.replace(/^.*\.(.*)\s.*$/,&quot;$1&quot;),10),q[2]=/[a-zA-Z]/.test(r)?parseInt(r.replace(/^.*[a-zA-Z]+(.*)$/,&quot;$1&quot;),10):0);else if(typeof h[[&quot;Active&quot;].concat(&quot;Object&quot;).join(&quot;X&quot;)]!=a)try{var s=new(window[[&quot;Active&quot;].concat(&quot;Object&quot;).join(&quot;X&quot;)])(d);s&amp;&amp;(r=s.GetVariable(&quot;$version&quot;),r&amp;&amp;(p=!0,r=r.split(&quot; &quot;)[1].split(&quot;,&quot;),q=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10)]))}catch(t){}return{w3:f,pv:q,wk:o,ie:p,win:m,mac:n}}(),z=function(){if(!y.w3)return;(typeof i.readyState!=a&amp;&amp;i.readyState==&quot;complete&quot;||typeof i.readyState==a&amp;&amp;(i.getElementsByTagName(&quot;body&quot;)[0]||i.body))&amp;&amp;A(),t||(typeof i.addEventListener!=a&amp;&amp;i.addEventListener(&quot;DOMContentLoaded&quot;,A,!1),y.ie&amp;&amp;y.win&amp;&amp;(i.attachEvent(g,function(){i.readyState==&quot;complete&quot;&amp;&amp;(i.detachEvent(g,arguments.callee),A())}),h==top&amp;&amp;function(){if(t)return;try{i.documentElement.doScroll(&quot;left&quot;)}catch(a){setTimeout(arguments.callee,0);return}A()}()),y.wk&amp;&amp;function(){if(t)return;if(!/loaded|complete/.test(i.readyState)){setTimeout(arguments.callee,0);return}A()}(),C(A))}(),W=function(){y.ie&amp;&amp;y.win&amp;&amp;window.attachEvent(&quot;onunload&quot;,function(){var a=o.length;for(var b=0;b&lt;a;b++)o[b][0].detachEvent(o[b][1],o[b][2]);var c=n.length;for(var d=0;d&lt;c;d++)N(n[d]);for(var e in y)y[e]=null;y=null;for(var f in swfobject)swfobject[f]=null;swfobject=null})}();return{registerObject:function(a,b,c,d){if(y.w3&amp;&amp;a&amp;&amp;b){var e={};e.id=a,e.swfVersion=b,e.expressInstall=c,e.callbackFn=d,m[m.length]=e,U(a,!1)}else d&amp;&amp;d({success:!1,id:a})},getObjectById:function(a){if(y.w3)return G(a)},embedSWF:function(c,d,e,f,g,h,i,j,k,l){var m={success:!1,id:d};y.w3&amp;&amp;!(y.wk&amp;&amp;y.wk&lt;312)&amp;&amp;c&amp;&amp;d&amp;&amp;e&amp;&amp;f&amp;&amp;g?(U(d,!1),B(function(){e+=&quot;&quot;,f+=&quot;&quot;;var n={};if(k&amp;&amp;typeof k===b)for(var o in k)n[o]=k[o];n.data=c,n.width=e,n.height=f;var p={};if(j&amp;&amp;typeof j===b)for(var q in j)p[q]=j[q];if(i&amp;&amp;typeof i===b)for(var r in i)typeof p.flashvars!=a?p.flashvars+=&quot;&amp;&quot;+r+&quot;=&quot;+i[r]:p.flashvars=r+&quot;=&quot;+i[r];if(S(g)){var s=L(n,p,d);n.id==d&amp;&amp;U(d,!0),m.success=!0,m.ref=s}else{if(h&amp;&amp;H()){n.data=h,I(n,p,d,l);return}U(d,!0)}l&amp;&amp;l(m)})):l&amp;&amp;l(m)},switchOffAutoHideShow:function(){x=!1},ua:y,getFlashPlayerVersion:function(){return{major:y.pv[0],minor:y.pv[1],release:y.pv[2]}},hasFlashPlayerVersion:S,createSWF:function(a,b,c){return y.w3?L(a,b,c):undefined},showExpressInstall:function(a,b,c,d){y.w3&amp;&amp;H()&amp;&amp;I(a,b,c,d)},removeSWF:function(a){y.w3&amp;&amp;N(a)},createCSS:function(a,b,c,d){y.w3&amp;&amp;T(a,b,c,d)},addDomLoadEvent:B,addLoadEvent:C,getQueryParamValue:function(a){var b=i.location.search||i.location.hash;if(b){/\?/.test(b)&amp;&amp;(b=b.split(&quot;?&quot;)[1]);if(a==null)return V(b);var c=b.split(&quot;&amp;&quot;);for(var d=0;d&lt;c.length;d++)if(c[d].substring(0,c[d].indexOf(&quot;=&quot;))==a)return V(c[d].substring(c[d].indexOf(&quot;=&quot;)+1))}return&quot;&quot;},expressInstallCallback:function(){if(u){var a=P(f);a&amp;&amp;p&amp;&amp;(a.parentNode.replaceChild(p,a),q&amp;&amp;(U(q,!0),y.ie&amp;&amp;y.win&amp;&amp;(p.style.display=&quot;block&quot;)),r&amp;&amp;r(s)),u=!1}}}}();(function(){if(&quot;undefined&quot;==typeof window||window.WebSocket)return;var a=window.console;if(!a||!a.log||!a.error)a={log:function(){},error:function(){}};if(!swfobject.hasFlashPlayerVersion(&quot;10.0.0&quot;)){a.error(&quot;Flash Player &gt;= 10.0.0 is required.&quot;);return}location.protocol==&quot;file:&quot;&amp;&amp;a.error(&quot;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://...&quot;),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==&quot;string&quot;&amp;&amp;(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&quot;INVALID_STATE_ERR: Web Socket connection has not been established&quot;;var b=WebSocket.__flash.send(this.__id,encodeURIComponent(a));return b&lt;0?!0:(this.bufferedAmount+=b,!1)},WebSocket.prototype.close=function(){if(this.readyState==WebSocket.CLOSED||this.readyState==WebSocket.CLOSING)return;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))return;var d=this.__events[a];for(var e=d.length-1;e&gt;=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&lt;b.length;++c)b[c](a);var d=this[&quot;on&quot;+a.type];d&amp;&amp;d(a)},WebSocket.prototype.__handleEvent=function(a){&quot;readyState&quot;in a&amp;&amp;(this.readyState=a.readyState),&quot;protocol&quot;in a&amp;&amp;(this.protocol=a.protocol);var b;if(a.type==&quot;open&quot;||a.type==&quot;error&quot;)b=this.__createSimpleEvent(a.type);else if(a.type==&quot;close&quot;)b=this.__createSimpleEvent(&quot;close&quot;);else{if(a.type!=&quot;message&quot;)throw&quot;unknown event type: &quot;+a.type;var c=decodeURIComponent(a.message);b=this.__createMessageEvent(&quot;message&quot;,c)}this.dispatchEvent(b)},WebSocket.prototype.__createSimpleEvent=function(a){if(document.createEvent&amp;&amp;window.Event){var b=document.createEvent(&quot;Event&quot;);return b.initEvent(a,!1,!1),b}return{type:a,bubbles:!1,cancelable:!1}},WebSocket.prototype.__createMessageEvent=function(a,b){if(document.createEvent&amp;&amp;window.MessageEvent&amp;&amp;!window.opera){var c=document.createEvent(&quot;MessageEvent&quot;);return c.initMessageEvent(&quot;message&quot;,!1,!1,b,null,null,window,null),c}return{type:a,data:b,bubbles:!1,cancelable:!1}},WebSocket.CONNECTING=0,WebSocket.OPEN=1,WebSocket.CLOSING=2,WebSocket.CLOSED=3,WebSocket.__flash=null,WebSocket.__instances={},WebSocket.__tasks=[],WebSocket.__nextId=0,WebSocket.loadFlashPolicyFile=function(a){WebSocket.__addTask(function(){WebSocket.__flash.loadManualPolicyFile(a)})},WebSocket.__initialize=function(){if(WebSocket.__flash)return;WebSocket.__swfLocation&amp;&amp;(window.WEB_SOCKET_SWF_LOCATION=WebSocket.__swfLocation);if(!window.WEB_SOCKET_SWF_LOCATION){a.error(&quot;[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf&quot;);return}var b=document.createElement(&quot;div&quot;);b.id=&quot;webSocketContainer&quot;,b.style.position=&quot;absolute&quot;,WebSocket.__isFlashLite()?(b.style.left=&quot;0px&quot;,b.style.top=&quot;0px&quot;):(b.style.left=&quot;-100px&quot;,b.style.top=&quot;-100px&quot;);var c=document.createElement(&quot;div&quot;);c.id=&quot;webSocketFlash&quot;,b.appendChild(c),document.body.appendChild(b),swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,&quot;webSocketFlash&quot;,&quot;1&quot;,&quot;1&quot;,&quot;10.0.0&quot;,null,null,{hasPriority:!0,swliveconnect:!0,allowScriptAccess:&quot;always&quot;},null,function(b){b.success||a.error(&quot;[WebSocket] swfobject.embedSWF failed&quot;)})},WebSocket.__onFlashInitialized=function(){setTimeout(function(){WebSocket.__flash=document.getElementById(&quot;webSocketFlash&quot;),WebSocket.__flash.setCallerUrl(location.href),WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var a=0;a&lt;WebSocket.__tasks.length;++a)WebSocket.__tasks[a]();WebSocket.__tasks=[]},0)},WebSocket.__onFlashEvent=function(){return setTimeout(function(){try{var b=WebSocket.__flash.receiveEvents();for(var c=0;c&lt;b.length;++c)WebSocket.__instances[b[c].webSocketId].__handleEvent(b[c])}catch(d){a.error(d)}},0),!0},WebSocket.__log=function(b){a.log(decodeURIComponent(b))},WebSocket.__error=function(b){a.error(decodeURIComponent(b))},WebSocket.__addTask=function(a){WebSocket.__flash?a():WebSocket.__tasks.push(a)},WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes)return!1;var a=window.navigator.mimeTypes[&quot;application/x-shockwave-flash&quot;];return!a||!a.enabledPlugin||!a.enabledPlugin.filename?!1:a.enabledPlugin.filename.match(/flashlite/i)?!0:!1},window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION||(window.addEventListener?window.addEventListener(&quot;load&quot;,function(){WebSocket.__initialize()},!1):window.attachEvent(&quot;onload&quot;,function(){WebSocket.__initialize()}))})(),function(a,b,c){function d(a){if(!a)return;b.Transport.apply(this,arguments),this.sendBuffer=[]}function e(){}a.XHR=d,b.util.inherit(d,b.Transport),d.prototype.open=function(){return this.socket.setBuffer(!1),this.onOpen(),this.get(),this.setCloseTimeout(),this},d.prototype.payload=function(a){var c=[];for(var d=0,e=a.length;d&lt;e;d++)c.push(b.parser.encodePacket(a[d]));this.send(b.parser.encodePayload(c))},d.prototype.send=function(a){return this.post(a),this},d.prototype.post=function(a){function d(){this.readyState==4&amp;&amp;(this.onreadystatechange=e,b.posting=!1,this.status==200?b.socket.setBuffer(!1):b.onClose())}function f(){this.onload=e,b.socket.setBuffer(!1)}var b=this;this.socket.setBuffer(!0),this.sendXHR=this.request(&quot;POST&quot;),c.XDomainRequest&amp;&amp;this.sendXHR instanceof XDomainRequest?this.sendXHR.onload=this.sendXHR.onerror=f:this.sendXHR.onreadystatechange=d,this.sendXHR.send(a)},d.prototype.close=function(){return this.onClose(),this},d.prototype.request=function(a){var c=b.util.request(this.socket.isXDomain()),d=b.util.query(this.socket.options.query,&quot;t=&quot;+ +(new Date));c.open(a||&quot;GET&quot;,this.prepareUrl()+d,!0);if(a==&quot;POST&quot;)try{c.setRequestHeader?c.setRequestHeader(&quot;Content-type&quot;,&quot;text/plain;charset=UTF-8&quot;):c.contentType=&quot;text/plain&quot;}catch(e){}return c},d.prototype.scheme=function(){return this.socket.options.secure?&quot;https&quot;:&quot;http&quot;},d.check=function(a,d){try{var e=b.util.request(d),f=c.XDomainRequest&amp;&amp;e instanceof XDomainRequest,g=a&amp;&amp;a.options&amp;&amp;a.options.secure?&quot;https:&quot;:&quot;http:&quot;,h=c.location&amp;&amp;g!=c.location.protocol;if(e&amp;&amp;(!f||!h))return!0}catch(i){}return!1},d.xdomainCheck=function(a){return d.check(a,!0)}}(&quot;undefined&quot;!=typeof io?io.Transport:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports,this),function(a,b){function c(a){b.Transport.XHR.apply(this,arguments)}a.htmlfile=c,b.util.inherit(c,b.Transport.XHR),c.prototype.name=&quot;htmlfile&quot;,c.prototype.get=function(){this.doc=new(window[[&quot;Active&quot;].concat(&quot;Object&quot;).join(&quot;X&quot;)])(&quot;htmlfile&quot;),this.doc.open(),this.doc.write(&quot;&lt;html&gt;&lt;/html&gt;&quot;),this.doc.close(),this.doc.parentWindow.s=this;var a=this.doc.createElement(&quot;div&quot;);a.className=&quot;socketio&quot;,this.doc.body.appendChild(a),this.iframe=this.doc.createElement(&quot;iframe&quot;),a.appendChild(this.iframe);var c=this,d=b.util.query(this.socket.options.query,&quot;t=&quot;+ +(new Date));this.iframe.src=this.prepareUrl()+d,b.util.on(window,&quot;unload&quot;,function(){c.destroy()})},c.prototype._=function(a,b){this.onData(a);try{var c=b.getElementsByTagName(&quot;script&quot;)[0];c.parentNode.removeChild(c)}catch(d){}},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src=&quot;about:blank&quot;}catch(a){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,CollectGarbage()}},c.prototype.close=function(){return this.destroy(),b.Transport.XHR.prototype.close.call(this)},c.check=function(a){if(typeof window!=&quot;undefined&quot;&amp;&amp;[&quot;Active&quot;].concat(&quot;Object&quot;).join(&quot;X&quot;)in window)try{var c=new(window[[&quot;Active&quot;].concat(&quot;Object&quot;).join(&quot;X&quot;)])(&quot;htmlfile&quot;);return c&amp;&amp;b.Transport.XHR.check(a)}catch(d){}return!1},c.xdomainCheck=function(){return!1},b.transports.push(&quot;htmlfile&quot;)}(&quot;undefined&quot;!=typeof io?io.Transport:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports),function(a,b,c){function d(){b.Transport.XHR.apply(this,arguments)}function e(){}a[&quot;xhr-polling&quot;]=d,b.util.inherit(d,b.Transport.XHR),b.util.merge(d,b.Transport.XHR),d.prototype.name=&quot;xhr-polling&quot;,d.prototype.heartbeats=function(){return!1},d.prototype.open=function(){var a=this;return b.Transport.XHR.prototype.open.call(a),!1},d.prototype.get=function(){function b(){this.readyState==4&amp;&amp;(this.onreadystatechange=e,this.status==200?(a.onData(this.responseText),a.get()):a.onClose())}function d(){this.onload=e,this.onerror=e,a.retryCounter=1,a.onData(this.responseText),a.get()}function f(){a.retryCounter++,!a.retryCounter||a.retryCounter&gt;3?a.onClose():a.get()}if(!this.isOpen)return;var a=this;this.xhr=this.request(),c.XDomainRequest&amp;&amp;this.xhr instanceof XDomainRequest?(this.xhr.onload=d,this.xhr.onerror=f):this.xhr.onreadystatechange=b,this.xhr.send(null)},d.prototype.onClose=function(){b.Transport.XHR.prototype.onClose.call(this);if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=e;try{this.xhr.abort()}catch(a){}this.xhr=null}},d.prototype.ready=function(a,c){var d=this;b.util.defer(function(){c.call(d)})},b.transports.push(&quot;xhr-polling&quot;)}(&quot;undefined&quot;!=typeof io?io.Transport:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports,this),function(a,b,c){function e(a){b.Transport[&quot;xhr-polling&quot;].apply(this,arguments),this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}var d=c.document&amp;&amp;&quot;MozAppearance&quot;in c.document.documentElement.style;a[&quot;jsonp-polling&quot;]=e,b.util.inherit(e,b.Transport[&quot;xhr-polling&quot;]),e.prototype.name=&quot;jsonp-polling&quot;,e.prototype.post=function(a){function i(){j(),c.socket.setBuffer(!1)}function j(){c.iframe&amp;&amp;c.form.removeChild(c.iframe);try{h=document.createElement('&lt;iframe name=&quot;'+c.iframeId+'&quot;&gt;')}catch(a){h=document.createElement(&quot;iframe&quot;),h.name=c.iframeId}h.id=c.iframeId,c.form.appendChild(h),c.iframe=h}var c=this,d=b.util.query(this.socket.options.query,&quot;t=&quot;+ +(new Date)+&quot;&amp;i=&quot;+this.index);if(!this.form){var e=document.createElement(&quot;form&quot;),f=document.createElement(&quot;textarea&quot;),g=this.iframeId=&quot;socketio_iframe_&quot;+this.index,h;e.className=&quot;socketio&quot;,e.style.position=&quot;absolute&quot;,e.style.top=&quot;0px&quot;,e.style.left=&quot;0px&quot;,e.style.display=&quot;none&quot;,e.target=g,e.method=&quot;POST&quot;,e.setAttribute(&quot;accept-charset&quot;,&quot;utf-8&quot;),f.name=&quot;d&quot;,e.appendChild(f),document.body.appendChild(e),this.form=e,this.area=f}this.form.action=this.prepareUrl()+d,j(),this.area.value=b.JSON.stringify(a);try{this.form.submit()}catch(k){}this.iframe.attachEvent?h.onreadystatechange=function(){c.iframe.readyState==&quot;complete&quot;&amp;&amp;i()}:this.iframe.onload=i,this.socket.setBuffer(!0)},e.prototype.get=function(){var a=this,c=document.createElement(&quot;script&quot;),e=b.util.query(this.socket.options.query,&quot;t=&quot;+ +(new Date)+&quot;&amp;i=&quot;+this.index);this.script&amp;&amp;(this.script.parentNode.removeChild(this.script),this.script=null),c.async=!0,c.src=this.prepareUrl()+e,c.onerror=function(){a.onClose()};var f=document.getElementsByTagName(&quot;script&quot;)[0];f.parentNode.insertBefore(c,f),this.script=c,d&amp;&amp;setTimeout(function(){var a=document.createElement(&quot;iframe&quot;);document.body.appendChild(a),document.body.removeChild(a)},100)},e.prototype._=function(a){return this.onData(a),this.isOpen&amp;&amp;this.get(),this},e.prototype.ready=function(a,c){var e=this;if(!d)return c.call(this);b.util.load(function(){c.call(e)})},e.check=function(){return&quot;document&quot;in c},e.xdomainCheck=function(){return!0},b.transports.push(&quot;jsonp-polling&quot;)}(&quot;undefined&quot;!=typeof io?io.Transport:module.exports,&quot;undefined&quot;!=typeof io?io:module.parent.exports,this),typeof define==&quot;function&quot;&amp;&amp;define.amd&amp;&amp;define([],function(){return io})})()</div></pre></div>
664          </td>
socket.io.js https://github.com/eiriklv/socket.io.git | JavaScript | 1,167 lines
187        request(srv)
188        .get('/socket.io/socket.io.js')
189        .end(function(err, res){
364          sio.of('/news', function(socket){
365            expect(socket).to.be.a(Socket);
366            --total || done();
1027  describe('middleware', function(done){
1028    var Socket = require('../lib/socket');
1029
1034      sio.use(function(socket, next){
1035        expect(socket).to.be.a(Socket);
1036        run++;
1039      sio.use(function(socket, next){
1040        expect(socket).to.be.a(Socket);
1041        run++;
shd-socket.c https://github.com/amiller/shadow.git | C | 432 lines
71
72void socket_init(Socket* socket, SocketFunctionTable* vtable, DescriptorType type, gint handle,
73		guint receiveBufferSize, guint sendBufferSize) {
90	Descriptor* descriptor = (Descriptor *)socket;
91	tracker_addSocket(tracker, descriptor->handle, socket->protocol, socket->inputBufferSize, socket->outputBufferSize);
92}
176
177gboolean socket_getSocketName(Socket* socket, in_addr_t* ip, in_port_t* port) {
178	MAGIC_ASSERT(socket);
194
195void socket_setSocketName(Socket* socket, in_addr_t ip, in_port_t port, gboolean isInternal) {
196	MAGIC_ASSERT(socket);
416    MAGIC_ASSERT(socket);
417    socket->flags = isUnixSocket ? (socket->flags | SF_UNIX) : (socket->flags & ~SF_UNIX);
418}
socket.io.js https://github.com/petey/socket.io-client.git | JavaScript | 5,966 lines
1445
1446Socket.Socket = Socket;
1447Socket.Transport = require('./transport');
1506  var transport;
1507  if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
1508    transport = 'websocket';
1581        self.emit('upgrading', transport);
1582        Socket.priorWebsocketSuccess = 'websocket' == transport.name;
1583
1679  this.readyState = 'open';
1680  Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
1681  this.emit('open');
4299
4300var WebSocket = global.WebSocket || global.MozWebSocket;
4301
socket.io.js https://github.com/Panoptico/NetSense.git | JavaScript | 6,173 lines
1650
1651Socket.Socket = Socket;
1652Socket.Transport = require('./transport');
1711  var transport;
1712  if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
1713    transport = 'websocket';
1786        self.emit('upgrading', transport);
1787        Socket.priorWebsocketSuccess = 'websocket' == transport.name;
1788
1884  this.readyState = 'open';
1885  Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
1886  this.emit('open');
4493
4494var WebSocket = global.WebSocket || global.MozWebSocket;
4495
socket.io.js https://github.com/kirillKey/questSearchTrain.git | JavaScript | 6,253 lines
1515
1516Socket.Socket = Socket;
1517Socket.Transport = _dereq_('./transport');
1578  var transport;
1579  if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
1580    transport = 'websocket';
1671        if (!transport) return;
1672        Socket.priorWebsocketSuccess = 'websocket' == transport.name;
1673
1767  this.readyState = 'open';
1768  Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
1769  this.emit('open');
4551
4552var WebSocket = global.WebSocket || global.MozWebSocket;
4553
socket.c https://github.com/ahwuyeah/ruby.git | C | 2,178 lines
253 *   Socket.pair(domain, type, protocol)       => [socket1, socket2]
254 *   Socket.socketpair(domain, type, protocol) => [socket1, socket2]
255 *
2043     * machine or between different machines.  There are many types of socket:
2044     * TCPSocket, UDPSocket or UNIXSocket for example.
2045     *
2072     *
2073     * Many of the classes, such as TCPSocket, UDPSocket or UNIXSocket,
2074     * ease the use of sockets comparatively to the equivalent C programming interface.
2141     */
2142    rb_cSocket = rb_define_class("Socket", rb_cBasicSocket);
2143
2157
2158    rb_define_singleton_method(rb_cSocket, "socketpair", rsock_sock_s_socketpair, -1);
2159    rb_define_singleton_method(rb_cSocket, "pair", rsock_sock_s_socketpair, -1);
socket.io.js https://github.com/FreePBX/ucp.git | JavaScript | 6,194 lines
1492
1493Socket.Socket = Socket;
1494Socket.Transport = _dereq_('./transport');
1555  var transport;
1556  if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
1557    transport = 'websocket';
1647        self.emit('upgrading', transport);
1648        Socket.priorWebsocketSuccess = 'websocket' == transport.name;
1649
1745  this.readyState = 'open';
1746  Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
1747  this.emit('open');
4492
4493var WebSocket = global.WebSocket || global.MozWebSocket;
4494
socket.io.js https://github.com/svlsummerjam/Arduino-angular-socketio-phonegap-app.git | JavaScript | 6,066 lines
1544
1545Socket.Socket = Socket;
1546Socket.Transport = require('./transport');
1608  var transport;
1609  if (this.rememberUpgrade && Socket.priorWebsocketSuccess && this.transports.indexOf('websocket') != -1) {
1610    transport = 'websocket';
1683        self.emit('upgrading', transport);
1684        Socket.priorWebsocketSuccess = 'websocket' == transport.name;
1685
1756  this.readyState = 'open';
1757  Socket.priorWebsocketSuccess = 'websocket' == this.transport.name;
1758  this.emit('open');
4404
4405var WebSocket = global.WebSocket || global.MozWebSocket;
4406
socket.io.js https://github.com/narcisoguillen/socket.io.git | JavaScript | 1,326 lines
187        request(srv)
188        .get('/socket.io/socket.io.js')
189        .end(function(err, res){
364          sio.of('/news', function(socket){
365            expect(socket).to.be.a(Socket);
366            --total || done();
1186  describe('middleware', function(done){
1187    var Socket = require('../lib/socket');
1188
1193      sio.use(function(socket, next){
1194        expect(socket).to.be.a(Socket);
1195        run++;
1198      sio.use(function(socket, next){
1199        expect(socket).to.be.a(Socket);
1200        run++;
socket.io.js https://github.com/JoshElias/EmberSkeleton.git | JavaScript | 7,591 lines
12    
13    <title>socket.io-client/socket.io.js at master · Automattic/socket.io-client</title>
14    <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub" />
22      <meta content="@github" name="twitter:site" /><meta content="summary" name="twitter:card" /><meta content="Automattic/socket.io-client" name="twitter:title" /><meta content="socket.io-client - Realtime application framework (client)" name="twitter:description" /><meta content="https://avatars2.githubusercontent.com/u/887802?s=400" name="twitter:image:src" />
23<meta content="GitHub" property="og:site_name" /><meta content="object" property="og:type" /><meta content="https://avatars2.githubusercontent.com/u/887802?s=400" property="og:image" /><meta content="Automattic/socket.io-client" property="og:title" /><meta content="https://github.com/Automattic/socket.io-client" property="og:url" /><meta content="socket.io-client - Realtime application framework (client)" property="og:description" />
24
324        <li>
325          <a href="/Automattic/socket.io-client/fork" class="minibutton with-count js-toggler-target fork-button lighter tooltipped-n" title="Fork your own copy of Automattic/socket.io-client to your account" aria-label="Fork your own copy of Automattic/socket.io-client to your account" rel="nofollow" data-method="post">
326            <span class="octicon octicon-repo-forked"></span>
463
464  <a href="github-windows://openRepo/https://github.com/Automattic/socket.io-client" class="minibutton sidebar-button" title="Save Automattic/socket.io-client to your computer and use it in GitHub Desktop." aria-label="Save Automattic/socket.io-client to your computer and use it in GitHub Desktop.">
465    <span class="octicon octicon-device-desktop"></span>
1224  <div class="breadcrumb">
1225    <span class='repo-root js-repo-root'><span itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/Automattic/socket.io-client" data-branch="master" data-direction="back" data-pjax="true" itemscope="url"><span itemprop="title">socket.io-client</span></a></span></span><span class="separator"> / </span><strong class="final-path">socket.io.js</strong>
1226  </div>
7503           </td>
7504           <td class="blob-line-code"><div class="code-body highlight"><pre><div class='line' id='LC1'><span class="o">!</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span><span class="s2">&quot;object&quot;</span><span class="o">==</span><span class="k">typeof</span> <span class="nx">exports</span><span class="o">?</span><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="o">=</span><span class="nx">e</span><span class="p">()</span><span class="o">:</span><span class="s2">&quot;function&quot;</span><span class="o">==</span><span class="k">typeof</span> <span class="nx">define</span><span class="o">&amp;&amp;</span><span class="nx">define</span><span class="p">.</span><span class="nx">amd</span><span class="o">?</span><span class="nx">define</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span><span class="o">:</span><span class="s2">&quot;undefined&quot;</span><span class="o">!=</span><span class="k">typeof</span> <span class="nb">window</span><span class="o">?</span><span class="nb">window</span><span class="p">.</span><span class="nx">io</span><span class="o">=</span><span class="nx">e</span><span class="p">()</span><span class="o">:</span><span class="s2">&quot;undefined&quot;</span><span class="o">!=</span><span class="k">typeof</span> <span class="nx">global</span><span class="o">?</span><span class="nx">global</span><span class="p">.</span><span class="nx">io</span><span class="o">=</span><span class="nx">e</span><span class="p">()</span><span class="o">:</span><span class="s2">&quot;undefined&quot;</span><span class="o">!=</span><span class="k">typeof</span> <span class="nx">self</span><span class="o">&amp;&amp;</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">io</span><span class="o">=</span><span class="nx">e</span><span class="p">())}(</span><span class="kd">function</span><span class="p">(){</span><span class="kd">var</span> <span class="nx">define</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">;</span></div><div class='line' id='LC2'><span class="k">return</span> <span class="p">(</span><span class="kd">function</span> <span class="nx">e</span><span class="p">(</span><span class="nx">t</span><span class="p">,</span><span class="nx">n</span><span class="p">,</span><span class="nx">r</span><span class="p">){</span><span class="kd">function</span> <span class="nx">s</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span><span class="nx">u</span><span class="p">){</span><span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">n</span><span class="p">[</span><span class="nx">o</span><span class="p">]){</span><span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">t</span><span class="p">[</span><span class="nx">o</span><span class="p">]){</span><span class="kd">var</span> <span class="nx">a</span><span class="o">=</span><span class="k">typeof</span> <span class="nx">require</span><span class="o">==</span><span class="s2">&quot;function&quot;</span><span class="o">&amp;&amp;</span><span class="nx">require</span><span class="p">;</span><span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">u</span><span class="o">&amp;&amp;</span><span class="nx">a</span><span class="p">)</span><span class="k">return</span> <span class="nx">a</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span><span class="o">!</span><span class="mi">0</span><span class="p">);</span><span class="k">if</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span><span class="k">return</span> <span class="nx">i</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span><span class="o">!</span><span class="mi">0</span><span class="p">);</span><span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">&quot;Cannot find module &#39;&quot;</span><span class="o">+</span><span class="nx">o</span><span class="o">+</span><span class="s2">&quot;&#39;&quot;</span><span class="p">)}</span><span class="kd">var</span> <span class="nx">f</span><span class="o">=</span><span class="nx">n</span><span class="p">[</span><span class="nx">o</span><span class="p">]</span><span class="o">=</span><span class="p">{</span><span class="nx">exports</span><span class="o">:</span><span class="p">{}};</span><span class="nx">t</span><span class="p">[</span><span class="nx">o</span><span class="p">][</span><span class="mi">0</span><span class="p">].</span><span class="nx">call</span><span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">exports</span><span class="p">,</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span><span class="kd">var</span> <span class="nx">n</span><span class="o">=</span><span class="nx">t</span><span class="p">[</span><span class="nx">o</span><span class="p">][</span><span class="mi">1</span><span class="p">][</span><span class="nx">e</span><span class="p">];</span><span class="k">return</span> <span class="nx">s</span><span class="p">(</span><span class="nx">n</span><span class="o">?</span><span class="nx">n</span><span class="o">:</span><span class="nx">e</span><span class="p">)},</span><span class="nx">f</span><span class="p">,</span><span class="nx">f</span><span class="p">.</span><span class="nx">exports</span><span class="p">,</span><span class="nx">e</span><span class="p">,</span><span class="nx">t</span><span class="p">,</span><span class="nx">n</span><span class="p">,</span><span class="nx">r</span><span class="p">)}</span><span class="k">return</span> <span class="nx">n</span><span class="p">[</span><span class="nx">o</span><span class="p">].</span><span class="nx">exports</span><span class="p">}</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="k">typeof</span> <span class="nx">require</span><span class="o">==</span><span class="s2">&quot;function&quot;</span><span class="o">&amp;&amp;</span><span class="nx">require</span><span class="p">;</span><span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">o</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="nx">o</span><span class="o">&lt;</span><span class="nx">r</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span><span class="nx">o</span><span class="o">++</span><span class="p">)</span><span class="nx">s</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">o</span><span class="p">]);</span><span class="k">return</span> <span class="nx">s</span><span class="p">})({</span><span class="mi">1</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC3'><br/></div><div class='line' id='LC4'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./lib/&#39;</span><span class="p">);</span></div><div class='line' id='LC5'><br/></div><div class='line' id='LC6'><span class="p">},{</span><span class="s2">&quot;./lib/&quot;</span><span class="o">:</span><span class="mi">2</span><span class="p">}],</span><span class="mi">2</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC7'><br/></div><div class='line' id='LC8'><span class="cm">/**</span></div><div class='line' id='LC9'><span class="cm"> * Module dependencies.</span></div><div class='line' id='LC10'><span class="cm"> */</span></div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'><span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./url&#39;</span><span class="p">);</span></div><div class='line' id='LC13'><span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;socket.io-parser&#39;</span><span class="p">);</span></div><div class='line' id='LC14'><span class="kd">var</span> <span class="nx">Manager</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./manager&#39;</span><span class="p">);</span></div><div class='line' id='LC15'><span class="kd">var</span> <span class="nx">debug</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;debug&#39;</span><span class="p">)(</span><span class="s1">&#39;socket.io-client&#39;</span><span class="p">);</span></div><div class='line' id='LC16'><br/></div><div class='line' id='LC17'><span class="cm">/**</span></div><div class='line' id='LC18'><span class="cm"> * Module exports.</span></div><div class='line' id='LC19'><span class="cm"> */</span></div><div class='line' id='LC20'><br/></div><div class='line' id='LC21'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">exports</span> <span class="o">=</span> <span class="nx">lookup</span><span class="p">;</span></div><div class='line' id='LC22'><br/></div><div class='line' id='LC23'><span class="cm">/**</span></div><div class='line' id='LC24'><span class="cm"> * Managers cache.</span></div><div class='line' id='LC25'><span class="cm"> */</span></div><div class='line' id='LC26'><br/></div><div class='line' id='LC27'><span class="kd">var</span> <span class="nx">cache</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">managers</span> <span class="o">=</span> <span class="p">{};</span></div><div class='line' id='LC28'><br/></div><div class='line' id='LC29'><span class="cm">/**</span></div><div class='line' id='LC30'><span class="cm"> * Looks up an existing `Manager` for multiplexing.</span></div><div class='line' id='LC31'><span class="cm"> * If the user summons:</span></div><div class='line' id='LC32'><span class="cm"> *</span></div><div class='line' id='LC33'><span class="cm"> *   `io(&#39;http://localhost/a&#39;);`</span></div><div class='line' id='LC34'><span class="cm"> *   `io(&#39;http://localhost/b&#39;);`</span></div><div class='line' id='LC35'><span class="cm"> *</span></div><div class='line' id='LC36'><span class="cm"> * We reuse the existing instance based on same scheme/port/host,</span></div><div class='line' id='LC37'><span class="cm"> * and we initialize sockets for each namespace.</span></div><div class='line' id='LC38'><span class="cm"> *</span></div><div class='line' id='LC39'><span class="cm"> * @api public</span></div><div class='line' id='LC40'><span class="cm"> */</span></div><div class='line' id='LC41'><br/></div><div class='line' id='LC42'><span class="kd">function</span> <span class="nx">lookup</span><span class="p">(</span><span class="nx">uri</span><span class="p">,</span> <span class="nx">opts</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC43'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">uri</span> <span class="o">==</span> <span class="s1">&#39;object&#39;</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">opts</span> <span class="o">=</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">uri</span> <span class="o">=</span> <span class="kc">undefined</span><span class="p">;</span></div><div class='line' id='LC46'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC47'><br/></div><div class='line' id='LC48'>&nbsp;&nbsp;<span class="nx">opts</span> <span class="o">=</span> <span class="nx">opts</span> <span class="o">||</span> <span class="p">{};</span></div><div class='line' id='LC49'><br/></div><div class='line' id='LC50'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">parsed</span> <span class="o">=</span> <span class="nx">url</span><span class="p">(</span><span class="nx">uri</span><span class="p">);</span></div><div class='line' id='LC51'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">source</span> <span class="o">=</span> <span class="nx">parsed</span><span class="p">.</span><span class="nx">source</span><span class="p">;</span></div><div class='line' id='LC52'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">parsed</span><span class="p">.</span><span class="nx">id</span><span class="p">;</span></div><div class='line' id='LC53'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">io</span><span class="p">;</span></div><div class='line' id='LC54'><br/></div><div class='line' id='LC55'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">opts</span><span class="p">.</span><span class="nx">forceNew</span> <span class="o">||</span> <span class="nx">opts</span><span class="p">[</span><span class="s1">&#39;force new connection&#39;</span><span class="p">]</span> <span class="o">||</span> <span class="kc">false</span> <span class="o">===</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">multiplex</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC56'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;ignoring socket cache for %s&#39;</span><span class="p">,</span> <span class="nx">source</span><span class="p">);</span></div><div class='line' id='LC57'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">io</span> <span class="o">=</span> <span class="nx">Manager</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">opts</span><span class="p">);</span></div><div class='line' id='LC58'>&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC59'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">cache</span><span class="p">[</span><span class="nx">id</span><span class="p">])</span> <span class="p">{</span></div><div class='line' id='LC60'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;new io instance for %s&#39;</span><span class="p">,</span> <span class="nx">source</span><span class="p">);</span></div><div class='line' id='LC61'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">cache</span><span class="p">[</span><span class="nx">id</span><span class="p">]</span> <span class="o">=</span> <span class="nx">Manager</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">opts</span><span class="p">);</span></div><div class='line' id='LC62'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC63'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">io</span> <span class="o">=</span> <span class="nx">cache</span><span class="p">[</span><span class="nx">id</span><span class="p">];</span></div><div class='line' id='LC64'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC65'><br/></div><div class='line' id='LC66'>&nbsp;&nbsp;<span class="k">return</span> <span class="nx">io</span><span class="p">.</span><span class="nx">socket</span><span class="p">(</span><span class="nx">parsed</span><span class="p">.</span><span class="nx">path</span><span class="p">);</span></div><div class='line' id='LC67'><span class="p">}</span></div><div class='line' id='LC68'><br/></div><div class='line' id='LC69'><span class="cm">/**</span></div><div class='line' id='LC70'><span class="cm"> * Protocol version.</span></div><div class='line' id='LC71'><span class="cm"> *</span></div><div class='line' id='LC72'><span class="cm"> * @api public</span></div><div class='line' id='LC73'><span class="cm"> */</span></div><div class='line' id='LC74'><br/></div><div class='line' id='LC75'><span class="nx">exports</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">=</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">protocol</span><span class="p">;</span></div><div class='line' id='LC76'><br/></div><div class='line' id='LC77'><span class="cm">/**</span></div><div class='line' id='LC78'><span class="cm"> * `connect`.</span></div><div class='line' id='LC79'><span class="cm"> *</span></div><div class='line' id='LC80'><span class="cm"> * @param {String} uri</span></div><div class='line' id='LC81'><span class="cm"> * @api public</span></div><div class='line' id='LC82'><span class="cm"> */</span></div><div class='line' id='LC83'><br/></div><div class='line' id='LC84'><span class="nx">exports</span><span class="p">.</span><span class="nx">connect</span> <span class="o">=</span> <span class="nx">lookup</span><span class="p">;</span></div><div class='line' id='LC85'><br/></div><div class='line' id='LC86'><span class="cm">/**</span></div><div class='line' id='LC87'><span class="cm"> * Expose constructors for standalone build.</span></div><div class='line' id='LC88'><span class="cm"> *</span></div><div class='line' id='LC89'><span class="cm"> * @api public</span></div><div class='line' id='LC90'><span class="cm"> */</span></div><div class='line' id='LC91'><br/></div><div class='line' id='LC92'><span class="nx">exports</span><span class="p">.</span><span class="nx">Manager</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./manager&#39;</span><span class="p">);</span></div><div class='line' id='LC93'><span class="nx">exports</span><span class="p">.</span><span class="nx">Socket</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./socket&#39;</span><span class="p">);</span></div><div class='line' id='LC94'><br/></div><div class='line' id='LC95'><span class="p">},{</span><span class="s2">&quot;./manager&quot;</span><span class="o">:</span><span class="mi">3</span><span class="p">,</span><span class="s2">&quot;./socket&quot;</span><span class="o">:</span><span class="mi">5</span><span class="p">,</span><span class="s2">&quot;./url&quot;</span><span class="o">:</span><span class="mi">6</span><span class="p">,</span><span class="s2">&quot;debug&quot;</span><span class="o">:</span><span class="mi">9</span><span class="p">,</span><span class="s2">&quot;socket.io-parser&quot;</span><span class="o">:</span><span class="mi">40</span><span class="p">}],</span><span class="mi">3</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC96'><br/></div><div class='line' id='LC97'><span class="cm">/**</span></div><div class='line' id='LC98'><span class="cm"> * Module dependencies.</span></div><div class='line' id='LC99'><span class="cm"> */</span></div><div class='line' id='LC100'><br/></div><div class='line' id='LC101'><span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./url&#39;</span><span class="p">);</span></div><div class='line' id='LC102'><span class="kd">var</span> <span class="nx">eio</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;engine.io-client&#39;</span><span class="p">);</span></div><div class='line' id='LC103'><span class="kd">var</span> <span class="nx">Socket</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./socket&#39;</span><span class="p">);</span></div><div class='line' id='LC104'><span class="kd">var</span> <span class="nx">Emitter</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;component-emitter&#39;</span><span class="p">);</span></div><div class='line' id='LC105'><span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;socket.io-parser&#39;</span><span class="p">);</span></div><div class='line' id='LC106'><span class="kd">var</span> <span class="nx">on</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./on&#39;</span><span class="p">);</span></div><div class='line' id='LC107'><span class="kd">var</span> <span class="nx">bind</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;component-bind&#39;</span><span class="p">);</span></div><div class='line' id='LC108'><span class="kd">var</span> <span class="nx">object</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;object-component&#39;</span><span class="p">);</span></div><div class='line' id='LC109'><span class="kd">var</span> <span class="nx">debug</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;debug&#39;</span><span class="p">)(</span><span class="s1">&#39;socket.io-client:manager&#39;</span><span class="p">);</span></div><div class='line' id='LC110'><br/></div><div class='line' id='LC111'><span class="cm">/**</span></div><div class='line' id='LC112'><span class="cm"> * Module exports</span></div><div class='line' id='LC113'><span class="cm"> */</span></div><div class='line' id='LC114'><br/></div><div class='line' id='LC115'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">Manager</span><span class="p">;</span></div><div class='line' id='LC116'><br/></div><div class='line' id='LC117'><span class="cm">/**</span></div><div class='line' id='LC118'><span class="cm"> * `Manager` constructor.</span></div><div class='line' id='LC119'><span class="cm"> *</span></div><div class='line' id='LC120'><span class="cm"> * @param {String} engine instance or engine uri/opts</span></div><div class='line' id='LC121'><span class="cm"> * @param {Object} options</span></div><div class='line' id='LC122'><span class="cm"> * @api public</span></div><div class='line' id='LC123'><span class="cm"> */</span></div><div class='line' id='LC124'><br/></div><div class='line' id='LC125'><span class="kd">function</span> <span class="nx">Manager</span><span class="p">(</span><span class="nx">uri</span><span class="p">,</span> <span class="nx">opts</span><span class="p">){</span></div><div class='line' id='LC126'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="k">this</span> <span class="k">instanceof</span> <span class="nx">Manager</span><span class="p">))</span> <span class="k">return</span> <span class="k">new</span> <span class="nx">Manager</span><span class="p">(</span><span class="nx">uri</span><span class="p">,</span> <span class="nx">opts</span><span class="p">);</span></div><div class='line' id='LC127'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">uri</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="s1">&#39;object&#39;</span> <span class="o">==</span> <span class="k">typeof</span> <span class="nx">uri</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC128'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">opts</span> <span class="o">=</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC129'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">uri</span> <span class="o">=</span> <span class="kc">undefined</span><span class="p">;</span></div><div class='line' id='LC130'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC131'>&nbsp;&nbsp;<span class="nx">opts</span> <span class="o">=</span> <span class="nx">opts</span> <span class="o">||</span> <span class="p">{};</span></div><div class='line' id='LC132'><br/></div><div class='line' id='LC133'>&nbsp;&nbsp;<span class="nx">opts</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">path</span> <span class="o">||</span> <span class="s1">&#39;/socket.io&#39;</span><span class="p">;</span></div><div class='line' id='LC134'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">nsps</span> <span class="o">=</span> <span class="p">{};</span></div><div class='line' id='LC135'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC136'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">opts</span> <span class="o">=</span> <span class="nx">opts</span><span class="p">;</span></div><div class='line' id='LC137'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnection</span><span class="p">(</span><span class="nx">opts</span><span class="p">.</span><span class="nx">reconnection</span> <span class="o">!==</span> <span class="kc">false</span><span class="p">);</span></div><div class='line' id='LC138'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnectionAttempts</span><span class="p">(</span><span class="nx">opts</span><span class="p">.</span><span class="nx">reconnectionAttempts</span> <span class="o">||</span> <span class="kc">Infinity</span><span class="p">);</span></div><div class='line' id='LC139'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnectionDelay</span><span class="p">(</span><span class="nx">opts</span><span class="p">.</span><span class="nx">reconnectionDelay</span> <span class="o">||</span> <span class="mi">1000</span><span class="p">);</span></div><div class='line' id='LC140'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnectionDelayMax</span><span class="p">(</span><span class="nx">opts</span><span class="p">.</span><span class="nx">reconnectionDelayMax</span> <span class="o">||</span> <span class="mi">5000</span><span class="p">);</span></div><div class='line' id='LC141'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">timeout</span><span class="p">(</span><span class="kc">null</span> <span class="o">==</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">timeout</span> <span class="o">?</span> <span class="mi">20000</span> <span class="o">:</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">timeout</span><span class="p">);</span></div><div class='line' id='LC142'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="s1">&#39;closed&#39;</span><span class="p">;</span></div><div class='line' id='LC143'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">uri</span> <span class="o">=</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC144'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">connected</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></div><div class='line' id='LC145'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">attempts</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></div><div class='line' id='LC146'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">encoding</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC147'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packetBuffer</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC148'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">encoder</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">Encoder</span><span class="p">();</span></div><div class='line' id='LC149'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">decoder</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">Decoder</span><span class="p">();</span></div><div class='line' id='LC150'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span></div><div class='line' id='LC151'><span class="p">}</span></div><div class='line' id='LC152'><br/></div><div class='line' id='LC153'><span class="cm">/**</span></div><div class='line' id='LC154'><span class="cm"> * Propagate given event to sockets and emit on `this`</span></div><div class='line' id='LC155'><span class="cm"> *</span></div><div class='line' id='LC156'><span class="cm"> * @api private</span></div><div class='line' id='LC157'><span class="cm"> */</span></div><div class='line' id='LC158'><br/></div><div class='line' id='LC159'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">emitAll</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC160'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">arguments</span><span class="p">);</span></div><div class='line' id='LC161'>&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">nsp</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsps</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC162'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">nsps</span><span class="p">[</span><span class="nx">nsp</span><span class="p">].</span><span class="nx">emit</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">nsps</span><span class="p">[</span><span class="nx">nsp</span><span class="p">],</span> <span class="nx">arguments</span><span class="p">);</span></div><div class='line' id='LC163'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC164'><span class="p">};</span></div><div class='line' id='LC165'><br/></div><div class='line' id='LC166'><span class="cm">/**</span></div><div class='line' id='LC167'><span class="cm"> * Mix in `Emitter`.</span></div><div class='line' id='LC168'><span class="cm"> */</span></div><div class='line' id='LC169'><br/></div><div class='line' id='LC170'><span class="nx">Emitter</span><span class="p">(</span><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">);</span></div><div class='line' id='LC171'><br/></div><div class='line' id='LC172'><span class="cm">/**</span></div><div class='line' id='LC173'><span class="cm"> * Sets the `reconnection` config.</span></div><div class='line' id='LC174'><span class="cm"> *</span></div><div class='line' id='LC175'><span class="cm"> * @param {Boolean} true/false if it should automatically reconnect</span></div><div class='line' id='LC176'><span class="cm"> * @return {Manager} self or value</span></div><div class='line' id='LC177'><span class="cm"> * @api public</span></div><div class='line' id='LC178'><span class="cm"> */</span></div><div class='line' id='LC179'><br/></div><div class='line' id='LC180'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">reconnection</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">){</span></div><div class='line' id='LC181'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_reconnection</span><span class="p">;</span></div><div class='line' id='LC182'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_reconnection</span> <span class="o">=</span> <span class="o">!!</span><span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC183'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC184'><span class="p">};</span></div><div class='line' id='LC185'><br/></div><div class='line' id='LC186'><span class="cm">/**</span></div><div class='line' id='LC187'><span class="cm"> * Sets the reconnection attempts config.</span></div><div class='line' id='LC188'><span class="cm"> *</span></div><div class='line' id='LC189'><span class="cm"> * @param {Number} max reconnection attempts before giving up</span></div><div class='line' id='LC190'><span class="cm"> * @return {Manager} self or value</span></div><div class='line' id='LC191'><span class="cm"> * @api public</span></div><div class='line' id='LC192'><span class="cm"> */</span></div><div class='line' id='LC193'><br/></div><div class='line' id='LC194'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">reconnectionAttempts</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">){</span></div><div class='line' id='LC195'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionAttempts</span><span class="p">;</span></div><div class='line' id='LC196'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionAttempts</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC197'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC198'><span class="p">};</span></div><div class='line' id='LC199'><br/></div><div class='line' id='LC200'><span class="cm">/**</span></div><div class='line' id='LC201'><span class="cm"> * Sets the delay between reconnections.</span></div><div class='line' id='LC202'><span class="cm"> *</span></div><div class='line' id='LC203'><span class="cm"> * @param {Number} delay</span></div><div class='line' id='LC204'><span class="cm"> * @return {Manager} self or value</span></div><div class='line' id='LC205'><span class="cm"> * @api public</span></div><div class='line' id='LC206'><span class="cm"> */</span></div><div class='line' id='LC207'><br/></div><div class='line' id='LC208'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">reconnectionDelay</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">){</span></div><div class='line' id='LC209'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionDelay</span><span class="p">;</span></div><div class='line' id='LC210'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionDelay</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC211'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC212'><span class="p">};</span></div><div class='line' id='LC213'><br/></div><div class='line' id='LC214'><span class="cm">/**</span></div><div class='line' id='LC215'><span class="cm"> * Sets the maximum delay between reconnections.</span></div><div class='line' id='LC216'><span class="cm"> *</span></div><div class='line' id='LC217'><span class="cm"> * @param {Number} delay</span></div><div class='line' id='LC218'><span class="cm"> * @return {Manager} self or value</span></div><div class='line' id='LC219'><span class="cm"> * @api public</span></div><div class='line' id='LC220'><span class="cm"> */</span></div><div class='line' id='LC221'><br/></div><div class='line' id='LC222'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">reconnectionDelayMax</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">){</span></div><div class='line' id='LC223'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionDelayMax</span><span class="p">;</span></div><div class='line' id='LC224'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionDelayMax</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC225'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC226'><span class="p">};</span></div><div class='line' id='LC227'><br/></div><div class='line' id='LC228'><span class="cm">/**</span></div><div class='line' id='LC229'><span class="cm"> * Sets the connection timeout. `false` to disable</span></div><div class='line' id='LC230'><span class="cm"> *</span></div><div class='line' id='LC231'><span class="cm"> * @return {Manager} self or value</span></div><div class='line' id='LC232'><span class="cm"> * @api public</span></div><div class='line' id='LC233'><span class="cm"> */</span></div><div class='line' id='LC234'><br/></div><div class='line' id='LC235'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">timeout</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">){</span></div><div class='line' id='LC236'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_timeout</span><span class="p">;</span></div><div class='line' id='LC237'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_timeout</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span></div><div class='line' id='LC238'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC239'><span class="p">};</span></div><div class='line' id='LC240'><br/></div><div class='line' id='LC241'><span class="cm">/**</span></div><div class='line' id='LC242'><span class="cm"> * Starts trying to reconnect if reconnection is enabled and we have not</span></div><div class='line' id='LC243'><span class="cm"> * started reconnecting yet</span></div><div class='line' id='LC244'><span class="cm"> *</span></div><div class='line' id='LC245'><span class="cm"> * @api private</span></div><div class='line' id='LC246'><span class="cm"> */</span></div><div class='line' id='LC247'><br/></div><div class='line' id='LC248'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">maybeReconnectOnOpen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC249'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">openReconnect</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">reconnecting</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_reconnection</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC250'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// keeps reconnection from firing twice for the same reconnection loop</span></div><div class='line' id='LC251'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">openReconnect</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC252'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnect</span><span class="p">();</span></div><div class='line' id='LC253'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC254'><span class="p">};</span></div><div class='line' id='LC255'><br/></div><div class='line' id='LC256'><br/></div><div class='line' id='LC257'><span class="cm">/**</span></div><div class='line' id='LC258'><span class="cm"> * Sets the current transport `socket`.</span></div><div class='line' id='LC259'><span class="cm"> *</span></div><div class='line' id='LC260'><span class="cm"> * @param {Function} optional, callback</span></div><div class='line' id='LC261'><span class="cm"> * @return {Manager} self</span></div><div class='line' id='LC262'><span class="cm"> * @api public</span></div><div class='line' id='LC263'><span class="cm"> */</span></div><div class='line' id='LC264'><br/></div><div class='line' id='LC265'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">open</span> <span class="o">=</span></div><div class='line' id='LC266'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">connect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">fn</span><span class="p">){</span></div><div class='line' id='LC267'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;readyState %s&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">readyState</span><span class="p">);</span></div><div class='line' id='LC268'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">~</span><span class="k">this</span><span class="p">.</span><span class="nx">readyState</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;open&#39;</span><span class="p">))</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC269'><br/></div><div class='line' id='LC270'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;opening %s&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">uri</span><span class="p">);</span></div><div class='line' id='LC271'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">engine</span> <span class="o">=</span> <span class="nx">eio</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">uri</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">opts</span><span class="p">);</span></div><div class='line' id='LC272'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">socket</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">engine</span><span class="p">;</span></div><div class='line' id='LC273'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC274'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="s1">&#39;opening&#39;</span><span class="p">;</span></div><div class='line' id='LC275'><br/></div><div class='line' id='LC276'>&nbsp;&nbsp;<span class="c1">// emit `open`</span></div><div class='line' id='LC277'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">openSub</span> <span class="o">=</span> <span class="nx">on</span><span class="p">(</span><span class="nx">socket</span><span class="p">,</span> <span class="s1">&#39;open&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC278'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">onopen</span><span class="p">();</span></div><div class='line' id='LC279'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">fn</span> <span class="o">&amp;&amp;</span> <span class="nx">fn</span><span class="p">();</span></div><div class='line' id='LC280'>&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC281'><br/></div><div class='line' id='LC282'>&nbsp;&nbsp;<span class="c1">// emit `connect_error`</span></div><div class='line' id='LC283'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">errorSub</span> <span class="o">=</span> <span class="nx">on</span><span class="p">(</span><span class="nx">socket</span><span class="p">,</span> <span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">){</span></div><div class='line' id='LC284'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;connect_error&#39;</span><span class="p">);</span></div><div class='line' id='LC285'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">cleanup</span><span class="p">();</span></div><div class='line' id='LC286'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="s1">&#39;closed&#39;</span><span class="p">;</span></div><div class='line' id='LC287'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;connect_error&#39;</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span></div><div class='line' id='LC288'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">fn</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC289'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">err</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;Connection error&#39;</span><span class="p">);</span></div><div class='line' id='LC290'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">err</span><span class="p">.</span><span class="nx">data</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span></div><div class='line' id='LC291'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">fn</span><span class="p">(</span><span class="nx">err</span><span class="p">);</span></div><div class='line' id='LC292'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC293'><br/></div><div class='line' id='LC294'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">maybeReconnectOnOpen</span><span class="p">();</span></div><div class='line' id='LC295'>&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC296'><br/></div><div class='line' id='LC297'>&nbsp;&nbsp;<span class="c1">// emit `connect_timeout`</span></div><div class='line' id='LC298'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="kc">false</span> <span class="o">!==</span> <span class="k">this</span><span class="p">.</span><span class="nx">_timeout</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC299'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">timeout</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_timeout</span><span class="p">;</span></div><div class='line' id='LC300'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;connect attempt will timeout after %d&#39;</span><span class="p">,</span> <span class="nx">timeout</span><span class="p">);</span></div><div class='line' id='LC301'><br/></div><div class='line' id='LC302'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// set timer</span></div><div class='line' id='LC303'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">timer</span> <span class="o">=</span> <span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC304'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;connect attempt timed out after %d&#39;</span><span class="p">,</span> <span class="nx">timeout</span><span class="p">);</span></div><div class='line' id='LC305'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">openSub</span><span class="p">.</span><span class="nx">destroy</span><span class="p">();</span></div><div class='line' id='LC306'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">socket</span><span class="p">.</span><span class="nx">close</span><span class="p">();</span></div><div class='line' id='LC307'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">socket</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="s1">&#39;timeout&#39;</span><span class="p">);</span></div><div class='line' id='LC308'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;connect_timeout&#39;</span><span class="p">,</span> <span class="nx">timeout</span><span class="p">);</span></div><div class='line' id='LC309'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">},</span> <span class="nx">timeout</span><span class="p">);</span></div><div class='line' id='LC310'><br/></div><div class='line' id='LC311'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span></div><div class='line' id='LC312'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">destroy</span><span class="o">:</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC313'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">clearTimeout</span><span class="p">(</span><span class="nx">timer</span><span class="p">);</span></div><div class='line' id='LC314'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC315'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC316'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC317'><br/></div><div class='line' id='LC318'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">openSub</span><span class="p">);</span></div><div class='line' id='LC319'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">errorSub</span><span class="p">);</span></div><div class='line' id='LC320'><br/></div><div class='line' id='LC321'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC322'><span class="p">};</span></div><div class='line' id='LC323'><br/></div><div class='line' id='LC324'><span class="cm">/**</span></div><div class='line' id='LC325'><span class="cm"> * Called upon transport open.</span></div><div class='line' id='LC326'><span class="cm"> *</span></div><div class='line' id='LC327'><span class="cm"> * @api private</span></div><div class='line' id='LC328'><span class="cm"> */</span></div><div class='line' id='LC329'><br/></div><div class='line' id='LC330'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onopen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC331'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;open&#39;</span><span class="p">);</span></div><div class='line' id='LC332'><br/></div><div class='line' id='LC333'>&nbsp;&nbsp;<span class="c1">// clear old subs</span></div><div class='line' id='LC334'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">cleanup</span><span class="p">();</span></div><div class='line' id='LC335'><br/></div><div class='line' id='LC336'>&nbsp;&nbsp;<span class="c1">// mark as open</span></div><div class='line' id='LC337'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="s1">&#39;open&#39;</span><span class="p">;</span></div><div class='line' id='LC338'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;open&#39;</span><span class="p">);</span></div><div class='line' id='LC339'><br/></div><div class='line' id='LC340'>&nbsp;&nbsp;<span class="c1">// add new subs</span></div><div class='line' id='LC341'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">socket</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">engine</span><span class="p">;</span></div><div class='line' id='LC342'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">on</span><span class="p">(</span><span class="nx">socket</span><span class="p">,</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;ondata&#39;</span><span class="p">)));</span></div><div class='line' id='LC343'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">on</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">decoder</span><span class="p">,</span> <span class="s1">&#39;decoded&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;ondecoded&#39;</span><span class="p">)));</span></div><div class='line' id='LC344'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">on</span><span class="p">(</span><span class="nx">socket</span><span class="p">,</span> <span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;onerror&#39;</span><span class="p">)));</span></div><div class='line' id='LC345'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">on</span><span class="p">(</span><span class="nx">socket</span><span class="p">,</span> <span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;onclose&#39;</span><span class="p">)));</span></div><div class='line' id='LC346'><span class="p">};</span></div><div class='line' id='LC347'><br/></div><div class='line' id='LC348'><span class="cm">/**</span></div><div class='line' id='LC349'><span class="cm"> * Called with data.</span></div><div class='line' id='LC350'><span class="cm"> *</span></div><div class='line' id='LC351'><span class="cm"> * @api private</span></div><div class='line' id='LC352'><span class="cm"> */</span></div><div class='line' id='LC353'><br/></div><div class='line' id='LC354'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">ondata</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">){</span></div><div class='line' id='LC355'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">decoder</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span></div><div class='line' id='LC356'><span class="p">};</span></div><div class='line' id='LC357'><br/></div><div class='line' id='LC358'><span class="cm">/**</span></div><div class='line' id='LC359'><span class="cm"> * Called when parser fully decodes a packet.</span></div><div class='line' id='LC360'><span class="cm"> *</span></div><div class='line' id='LC361'><span class="cm"> * @api private</span></div><div class='line' id='LC362'><span class="cm"> */</span></div><div class='line' id='LC363'><br/></div><div class='line' id='LC364'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">ondecoded</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">packet</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC365'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;packet&#39;</span><span class="p">,</span> <span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC366'><span class="p">};</span></div><div class='line' id='LC367'><br/></div><div class='line' id='LC368'><span class="cm">/**</span></div><div class='line' id='LC369'><span class="cm"> * Called upon socket error.</span></div><div class='line' id='LC370'><span class="cm"> *</span></div><div class='line' id='LC371'><span class="cm"> * @api private</span></div><div class='line' id='LC372'><span class="cm"> */</span></div><div class='line' id='LC373'><br/></div><div class='line' id='LC374'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onerror</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">){</span></div><div class='line' id='LC375'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="nx">err</span><span class="p">);</span></div><div class='line' id='LC376'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="nx">err</span><span class="p">);</span></div><div class='line' id='LC377'><span class="p">};</span></div><div class='line' id='LC378'><br/></div><div class='line' id='LC379'><span class="cm">/**</span></div><div class='line' id='LC380'><span class="cm"> * Creates a new socket for the given `nsp`.</span></div><div class='line' id='LC381'><span class="cm"> *</span></div><div class='line' id='LC382'><span class="cm"> * @return {Socket}</span></div><div class='line' id='LC383'><span class="cm"> * @api public</span></div><div class='line' id='LC384'><span class="cm"> */</span></div><div class='line' id='LC385'><br/></div><div class='line' id='LC386'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">socket</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">nsp</span><span class="p">){</span></div><div class='line' id='LC387'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">socket</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsps</span><span class="p">[</span><span class="nx">nsp</span><span class="p">];</span></div><div class='line' id='LC388'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">socket</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC389'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">socket</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Socket</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">nsp</span><span class="p">);</span></div><div class='line' id='LC390'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">nsps</span><span class="p">[</span><span class="nx">nsp</span><span class="p">]</span> <span class="o">=</span> <span class="nx">socket</span><span class="p">;</span></div><div class='line' id='LC391'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC392'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">socket</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;connect&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC393'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">connected</span><span class="o">++</span><span class="p">;</span></div><div class='line' id='LC394'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC395'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC396'>&nbsp;&nbsp;<span class="k">return</span> <span class="nx">socket</span><span class="p">;</span></div><div class='line' id='LC397'><span class="p">};</span></div><div class='line' id='LC398'><br/></div><div class='line' id='LC399'><span class="cm">/**</span></div><div class='line' id='LC400'><span class="cm"> * Called upon a socket close.</span></div><div class='line' id='LC401'><span class="cm"> *</span></div><div class='line' id='LC402'><span class="cm"> * @param {Socket} socket</span></div><div class='line' id='LC403'><span class="cm"> */</span></div><div class='line' id='LC404'><br/></div><div class='line' id='LC405'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">destroy</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">socket</span><span class="p">){</span></div><div class='line' id='LC406'>&nbsp;&nbsp;<span class="o">--</span><span class="k">this</span><span class="p">.</span><span class="nx">connected</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">close</span><span class="p">();</span></div><div class='line' id='LC407'><span class="p">};</span></div><div class='line' id='LC408'><br/></div><div class='line' id='LC409'><span class="cm">/**</span></div><div class='line' id='LC410'><span class="cm"> * Writes a packet.</span></div><div class='line' id='LC411'><span class="cm"> *</span></div><div class='line' id='LC412'><span class="cm"> * @param {Object} packet</span></div><div class='line' id='LC413'><span class="cm"> * @api private</span></div><div class='line' id='LC414'><span class="cm"> */</span></div><div class='line' id='LC415'><br/></div><div class='line' id='LC416'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">packet</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">packet</span><span class="p">){</span></div><div class='line' id='LC417'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;writing packet %j&#39;</span><span class="p">,</span> <span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC418'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC419'><br/></div><div class='line' id='LC420'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">self</span><span class="p">.</span><span class="nx">encoding</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC421'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// encode, then write to engine with result</span></div><div class='line' id='LC422'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">encoding</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC423'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">encoder</span><span class="p">.</span><span class="nx">encode</span><span class="p">(</span><span class="nx">packet</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">encodedPackets</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC424'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">encodedPackets</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC425'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">engine</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">encodedPackets</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span></div><div class='line' id='LC426'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC427'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">encoding</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC428'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">processPacketQueue</span><span class="p">();</span></div><div class='line' id='LC429'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC430'>&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="c1">// add packet to the queue</span></div><div class='line' id='LC431'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">packetBuffer</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC432'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC433'><span class="p">};</span></div><div class='line' id='LC434'><br/></div><div class='line' id='LC435'><span class="cm">/**</span></div><div class='line' id='LC436'><span class="cm"> * If packet buffer is non-empty, begins encoding the</span></div><div class='line' id='LC437'><span class="cm"> * next packet in line.</span></div><div class='line' id='LC438'><span class="cm"> *</span></div><div class='line' id='LC439'><span class="cm"> * @api private</span></div><div class='line' id='LC440'><span class="cm"> */</span></div><div class='line' id='LC441'><br/></div><div class='line' id='LC442'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">processPacketQueue</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC443'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">packetBuffer</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">encoding</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC444'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">pack</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">packetBuffer</span><span class="p">.</span><span class="nx">shift</span><span class="p">();</span></div><div class='line' id='LC445'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packet</span><span class="p">(</span><span class="nx">pack</span><span class="p">);</span></div><div class='line' id='LC446'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC447'><span class="p">};</span></div><div class='line' id='LC448'><br/></div><div class='line' id='LC449'><span class="cm">/**</span></div><div class='line' id='LC450'><span class="cm"> * Clean up transport subscriptions and packet buffer.</span></div><div class='line' id='LC451'><span class="cm"> *</span></div><div class='line' id='LC452'><span class="cm"> * @api private</span></div><div class='line' id='LC453'><span class="cm"> */</span></div><div class='line' id='LC454'><br/></div><div class='line' id='LC455'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">cleanup</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC456'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">sub</span><span class="p">;</span></div><div class='line' id='LC457'>&nbsp;&nbsp;<span class="k">while</span> <span class="p">(</span><span class="nx">sub</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">shift</span><span class="p">())</span> <span class="nx">sub</span><span class="p">.</span><span class="nx">destroy</span><span class="p">();</span></div><div class='line' id='LC458'><br/></div><div class='line' id='LC459'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packetBuffer</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC460'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">encoding</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC461'><br/></div><div class='line' id='LC462'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">decoder</span><span class="p">.</span><span class="nx">destroy</span><span class="p">();</span></div><div class='line' id='LC463'><span class="p">};</span></div><div class='line' id='LC464'><br/></div><div class='line' id='LC465'><span class="cm">/**</span></div><div class='line' id='LC466'><span class="cm"> * Close the current socket.</span></div><div class='line' id='LC467'><span class="cm"> *</span></div><div class='line' id='LC468'><span class="cm"> * @api private</span></div><div class='line' id='LC469'><span class="cm"> */</span></div><div class='line' id='LC470'><br/></div><div class='line' id='LC471'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">close</span> <span class="o">=</span></div><div class='line' id='LC472'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">disconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC473'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">skipReconnect</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC474'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">engine</span><span class="p">.</span><span class="nx">close</span><span class="p">();</span></div><div class='line' id='LC475'><span class="p">};</span></div><div class='line' id='LC476'><br/></div><div class='line' id='LC477'><span class="cm">/**</span></div><div class='line' id='LC478'><span class="cm"> * Called upon engine close.</span></div><div class='line' id='LC479'><span class="cm"> *</span></div><div class='line' id='LC480'><span class="cm"> * @api private</span></div><div class='line' id='LC481'><span class="cm"> */</span></div><div class='line' id='LC482'><br/></div><div class='line' id='LC483'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onclose</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">reason</span><span class="p">){</span></div><div class='line' id='LC484'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;close&#39;</span><span class="p">);</span></div><div class='line' id='LC485'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">cleanup</span><span class="p">();</span></div><div class='line' id='LC486'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">readyState</span> <span class="o">=</span> <span class="s1">&#39;closed&#39;</span><span class="p">;</span></div><div class='line' id='LC487'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="nx">reason</span><span class="p">);</span></div><div class='line' id='LC488'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_reconnection</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">skipReconnect</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC489'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnect</span><span class="p">();</span></div><div class='line' id='LC490'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC491'><span class="p">};</span></div><div class='line' id='LC492'><br/></div><div class='line' id='LC493'><span class="cm">/**</span></div><div class='line' id='LC494'><span class="cm"> * Attempt a reconnection.</span></div><div class='line' id='LC495'><span class="cm"> *</span></div><div class='line' id='LC496'><span class="cm"> * @api private</span></div><div class='line' id='LC497'><span class="cm"> */</span></div><div class='line' id='LC498'><br/></div><div class='line' id='LC499'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">reconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC500'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">reconnecting</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC501'><br/></div><div class='line' id='LC502'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC503'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">attempts</span><span class="o">++</span><span class="p">;</span></div><div class='line' id='LC504'><br/></div><div class='line' id='LC505'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">attempts</span> <span class="o">&gt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_reconnectionAttempts</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC506'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;reconnect failed&#39;</span><span class="p">);</span></div><div class='line' id='LC507'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;reconnect_failed&#39;</span><span class="p">);</span></div><div class='line' id='LC508'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnecting</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC509'>&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC510'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">delay</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">attempts</span> <span class="o">*</span> <span class="k">this</span><span class="p">.</span><span class="nx">reconnectionDelay</span><span class="p">();</span></div><div class='line' id='LC511'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">delay</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="nx">delay</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">reconnectionDelayMax</span><span class="p">());</span></div><div class='line' id='LC512'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;will wait %dms before reconnect attempt&#39;</span><span class="p">,</span> <span class="nx">delay</span><span class="p">);</span></div><div class='line' id='LC513'><br/></div><div class='line' id='LC514'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnecting</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC515'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">timer</span> <span class="o">=</span> <span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC516'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;attempting reconnect&#39;</span><span class="p">);</span></div><div class='line' id='LC517'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;reconnect_attempt&#39;</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">attempts</span><span class="p">);</span></div><div class='line' id='LC518'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;reconnecting&#39;</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">attempts</span><span class="p">);</span></div><div class='line' id='LC519'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">err</span><span class="p">){</span></div><div class='line' id='LC520'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC521'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;reconnect attempt error&#39;</span><span class="p">);</span></div><div class='line' id='LC522'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">reconnecting</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC523'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">reconnect</span><span class="p">();</span></div><div class='line' id='LC524'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;reconnect_error&#39;</span><span class="p">,</span> <span class="nx">err</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span></div><div class='line' id='LC525'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC526'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;reconnect success&#39;</span><span class="p">);</span></div><div class='line' id='LC527'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">onreconnect</span><span class="p">();</span></div><div class='line' id='LC528'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC529'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC530'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">},</span> <span class="nx">delay</span><span class="p">);</span></div><div class='line' id='LC531'><br/></div><div class='line' id='LC532'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">push</span><span class="p">({</span></div><div class='line' id='LC533'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">destroy</span><span class="o">:</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC534'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">clearTimeout</span><span class="p">(</span><span class="nx">timer</span><span class="p">);</span></div><div class='line' id='LC535'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC536'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC537'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC538'><span class="p">};</span></div><div class='line' id='LC539'><br/></div><div class='line' id='LC540'><span class="cm">/**</span></div><div class='line' id='LC541'><span class="cm"> * Called upon successful reconnect.</span></div><div class='line' id='LC542'><span class="cm"> *</span></div><div class='line' id='LC543'><span class="cm"> * @api private</span></div><div class='line' id='LC544'><span class="cm"> */</span></div><div class='line' id='LC545'><br/></div><div class='line' id='LC546'><span class="nx">Manager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onreconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC547'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">attempt</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">attempts</span><span class="p">;</span></div><div class='line' id='LC548'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">attempts</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></div><div class='line' id='LC549'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">reconnecting</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC550'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emitAll</span><span class="p">(</span><span class="s1">&#39;reconnect&#39;</span><span class="p">,</span> <span class="nx">attempt</span><span class="p">);</span></div><div class='line' id='LC551'><span class="p">};</span></div><div class='line' id='LC552'><br/></div><div class='line' id='LC553'><span class="p">},{</span><span class="s2">&quot;./on&quot;</span><span class="o">:</span><span class="mi">4</span><span class="p">,</span><span class="s2">&quot;./socket&quot;</span><span class="o">:</span><span class="mi">5</span><span class="p">,</span><span class="s2">&quot;./url&quot;</span><span class="o">:</span><span class="mi">6</span><span class="p">,</span><span class="s2">&quot;component-bind&quot;</span><span class="o">:</span><span class="mi">7</span><span class="p">,</span><span class="s2">&quot;component-emitter&quot;</span><span class="o">:</span><span class="mi">8</span><span class="p">,</span><span class="s2">&quot;debug&quot;</span><span class="o">:</span><span class="mi">9</span><span class="p">,</span><span class="s2">&quot;engine.io-client&quot;</span><span class="o">:</span><span class="mi">11</span><span class="p">,</span><span class="s2">&quot;object-component&quot;</span><span class="o">:</span><span class="mi">37</span><span class="p">,</span><span class="s2">&quot;socket.io-parser&quot;</span><span class="o">:</span><span class="mi">40</span><span class="p">}],</span><span class="mi">4</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC554'><br/></div><div class='line' id='LC555'><span class="cm">/**</span></div><div class='line' id='LC556'><span class="cm"> * Module exports.</span></div><div class='line' id='LC557'><span class="cm"> */</span></div><div class='line' id='LC558'><br/></div><div class='line' id='LC559'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">on</span><span class="p">;</span></div><div class='line' id='LC560'><br/></div><div class='line' id='LC561'><span class="cm">/**</span></div><div class='line' id='LC562'><span class="cm"> * Helper for subscriptions.</span></div><div class='line' id='LC563'><span class="cm"> *</span></div><div class='line' id='LC564'><span class="cm"> * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`</span></div><div class='line' id='LC565'><span class="cm"> * @param {String} event name</span></div><div class='line' id='LC566'><span class="cm"> * @param {Function} callback</span></div><div class='line' id='LC567'><span class="cm"> * @api public</span></div><div class='line' id='LC568'><span class="cm"> */</span></div><div class='line' id='LC569'><br/></div><div class='line' id='LC570'><span class="kd">function</span> <span class="nx">on</span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">ev</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC571'>&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="nx">ev</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span></div><div class='line' id='LC572'>&nbsp;&nbsp;<span class="k">return</span> <span class="p">{</span></div><div class='line' id='LC573'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">destroy</span><span class="o">:</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC574'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">removeListener</span><span class="p">(</span><span class="nx">ev</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span></div><div class='line' id='LC575'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC576'>&nbsp;&nbsp;<span class="p">};</span></div><div class='line' id='LC577'><span class="p">}</span></div><div class='line' id='LC578'><br/></div><div class='line' id='LC579'><span class="p">},{}],</span><span class="mi">5</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC580'><br/></div><div class='line' id='LC581'><span class="cm">/**</span></div><div class='line' id='LC582'><span class="cm"> * Module dependencies.</span></div><div class='line' id='LC583'><span class="cm"> */</span></div><div class='line' id='LC584'><br/></div><div class='line' id='LC585'><span class="kd">var</span> <span class="nx">parser</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;socket.io-parser&#39;</span><span class="p">);</span></div><div class='line' id='LC586'><span class="kd">var</span> <span class="nx">Emitter</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;component-emitter&#39;</span><span class="p">);</span></div><div class='line' id='LC587'><span class="kd">var</span> <span class="nx">toArray</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;to-array&#39;</span><span class="p">);</span></div><div class='line' id='LC588'><span class="kd">var</span> <span class="nx">on</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./on&#39;</span><span class="p">);</span></div><div class='line' id='LC589'><span class="kd">var</span> <span class="nx">bind</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;component-bind&#39;</span><span class="p">);</span></div><div class='line' id='LC590'><span class="kd">var</span> <span class="nx">debug</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;debug&#39;</span><span class="p">)(</span><span class="s1">&#39;socket.io-client:socket&#39;</span><span class="p">);</span></div><div class='line' id='LC591'><span class="kd">var</span> <span class="nx">hasBin</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;has-binary-data&#39;</span><span class="p">);</span></div><div class='line' id='LC592'><span class="kd">var</span> <span class="nx">indexOf</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;indexof&#39;</span><span class="p">);</span></div><div class='line' id='LC593'><br/></div><div class='line' id='LC594'><span class="cm">/**</span></div><div class='line' id='LC595'><span class="cm"> * Module exports.</span></div><div class='line' id='LC596'><span class="cm"> */</span></div><div class='line' id='LC597'><br/></div><div class='line' id='LC598'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">exports</span> <span class="o">=</span> <span class="nx">Socket</span><span class="p">;</span></div><div class='line' id='LC599'><br/></div><div class='line' id='LC600'><span class="cm">/**</span></div><div class='line' id='LC601'><span class="cm"> * Internal events (blacklisted).</span></div><div class='line' id='LC602'><span class="cm"> * These events can&#39;t be emitted by the user.</span></div><div class='line' id='LC603'><span class="cm"> *</span></div><div class='line' id='LC604'><span class="cm"> * @api private</span></div><div class='line' id='LC605'><span class="cm"> */</span></div><div class='line' id='LC606'><br/></div><div class='line' id='LC607'><span class="kd">var</span> <span class="nx">events</span> <span class="o">=</span> <span class="p">{</span></div><div class='line' id='LC608'>&nbsp;&nbsp;<span class="nx">connect</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC609'>&nbsp;&nbsp;<span class="nx">connect_error</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC610'>&nbsp;&nbsp;<span class="nx">connect_timeout</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC611'>&nbsp;&nbsp;<span class="nx">disconnect</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC612'>&nbsp;&nbsp;<span class="nx">error</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC613'>&nbsp;&nbsp;<span class="nx">reconnect</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC614'>&nbsp;&nbsp;<span class="nx">reconnect_attempt</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC615'>&nbsp;&nbsp;<span class="nx">reconnect_failed</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC616'>&nbsp;&nbsp;<span class="nx">reconnect_error</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span></div><div class='line' id='LC617'>&nbsp;&nbsp;<span class="nx">reconnecting</span><span class="o">:</span> <span class="mi">1</span></div><div class='line' id='LC618'><span class="p">};</span></div><div class='line' id='LC619'><br/></div><div class='line' id='LC620'><span class="cm">/**</span></div><div class='line' id='LC621'><span class="cm"> * Shortcut to `Emitter#emit`.</span></div><div class='line' id='LC622'><span class="cm"> */</span></div><div class='line' id='LC623'><br/></div><div class='line' id='LC624'><span class="kd">var</span> <span class="nx">emit</span> <span class="o">=</span> <span class="nx">Emitter</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">emit</span><span class="p">;</span></div><div class='line' id='LC625'><br/></div><div class='line' id='LC626'><span class="cm">/**</span></div><div class='line' id='LC627'><span class="cm"> * `Socket` constructor.</span></div><div class='line' id='LC628'><span class="cm"> *</span></div><div class='line' id='LC629'><span class="cm"> * @api public</span></div><div class='line' id='LC630'><span class="cm"> */</span></div><div class='line' id='LC631'><br/></div><div class='line' id='LC632'><span class="kd">function</span> <span class="nx">Socket</span><span class="p">(</span><span class="nx">io</span><span class="p">,</span> <span class="nx">nsp</span><span class="p">){</span></div><div class='line' id='LC633'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">io</span> <span class="o">=</span> <span class="nx">io</span><span class="p">;</span></div><div class='line' id='LC634'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">nsp</span> <span class="o">=</span> <span class="nx">nsp</span><span class="p">;</span></div><div class='line' id='LC635'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">json</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span> <span class="c1">// compat</span></div><div class='line' id='LC636'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">ids</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></div><div class='line' id='LC637'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">acks</span> <span class="o">=</span> <span class="p">{};</span></div><div class='line' id='LC638'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span></div><div class='line' id='LC639'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">receiveBuffer</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC640'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">sendBuffer</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC641'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">connected</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC642'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">disconnected</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC643'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subEvents</span><span class="p">();</span></div><div class='line' id='LC644'><span class="p">}</span></div><div class='line' id='LC645'><br/></div><div class='line' id='LC646'><span class="cm">/**</span></div><div class='line' id='LC647'><span class="cm"> * Mix in `Emitter`.</span></div><div class='line' id='LC648'><span class="cm"> */</span></div><div class='line' id='LC649'><br/></div><div class='line' id='LC650'><span class="nx">Emitter</span><span class="p">(</span><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">);</span></div><div class='line' id='LC651'><br/></div><div class='line' id='LC652'><span class="cm">/**</span></div><div class='line' id='LC653'><span class="cm"> * Subscribe to open, close and packet events</span></div><div class='line' id='LC654'><span class="cm"> *</span></div><div class='line' id='LC655'><span class="cm"> * @api private</span></div><div class='line' id='LC656'><span class="cm"> */</span></div><div class='line' id='LC657'><br/></div><div class='line' id='LC658'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">subEvents</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC659'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">io</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">io</span><span class="p">;</span></div><div class='line' id='LC660'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span> <span class="o">=</span> <span class="p">[</span></div><div class='line' id='LC661'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">on</span><span class="p">(</span><span class="nx">io</span><span class="p">,</span> <span class="s1">&#39;open&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;onopen&#39;</span><span class="p">)),</span></div><div class='line' id='LC662'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">on</span><span class="p">(</span><span class="nx">io</span><span class="p">,</span> <span class="s1">&#39;packet&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;onpacket&#39;</span><span class="p">)),</span></div><div class='line' id='LC663'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">on</span><span class="p">(</span><span class="nx">io</span><span class="p">,</span> <span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="nx">bind</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="s1">&#39;onclose&#39;</span><span class="p">))</span></div><div class='line' id='LC664'>&nbsp;&nbsp;<span class="p">];</span></div><div class='line' id='LC665'><span class="p">};</span></div><div class='line' id='LC666'><br/></div><div class='line' id='LC667'><span class="cm">/**</span></div><div class='line' id='LC668'><span class="cm"> * Called upon engine `open`.</span></div><div class='line' id='LC669'><span class="cm"> *</span></div><div class='line' id='LC670'><span class="cm"> * @api private</span></div><div class='line' id='LC671'><span class="cm"> */</span></div><div class='line' id='LC672'><br/></div><div class='line' id='LC673'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">open</span> <span class="o">=</span></div><div class='line' id='LC674'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">connect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC675'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connected</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC676'><br/></div><div class='line' id='LC677'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">io</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span> <span class="c1">// ensure open</span></div><div class='line' id='LC678'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;open&#39;</span> <span class="o">==</span> <span class="k">this</span><span class="p">.</span><span class="nx">io</span><span class="p">.</span><span class="nx">readyState</span><span class="p">)</span> <span class="k">this</span><span class="p">.</span><span class="nx">onopen</span><span class="p">();</span></div><div class='line' id='LC679'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC680'><span class="p">};</span></div><div class='line' id='LC681'><br/></div><div class='line' id='LC682'><span class="cm">/**</span></div><div class='line' id='LC683'><span class="cm"> * Sends a `message` event.</span></div><div class='line' id='LC684'><span class="cm"> *</span></div><div class='line' id='LC685'><span class="cm"> * @return {Socket} self</span></div><div class='line' id='LC686'><span class="cm"> * @api public</span></div><div class='line' id='LC687'><span class="cm"> */</span></div><div class='line' id='LC688'><br/></div><div class='line' id='LC689'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">send</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC690'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">toArray</span><span class="p">(</span><span class="nx">arguments</span><span class="p">);</span></div><div class='line' id='LC691'>&nbsp;&nbsp;<span class="nx">args</span><span class="p">.</span><span class="nx">unshift</span><span class="p">(</span><span class="s1">&#39;message&#39;</span><span class="p">);</span></div><div class='line' id='LC692'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span></div><div class='line' id='LC693'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC694'><span class="p">};</span></div><div class='line' id='LC695'><br/></div><div class='line' id='LC696'><span class="cm">/**</span></div><div class='line' id='LC697'><span class="cm"> * Override `emit`.</span></div><div class='line' id='LC698'><span class="cm"> * If the event is in `events`, it&#39;s emitted normally.</span></div><div class='line' id='LC699'><span class="cm"> *</span></div><div class='line' id='LC700'><span class="cm"> * @param {String} event name</span></div><div class='line' id='LC701'><span class="cm"> * @return {Socket} self</span></div><div class='line' id='LC702'><span class="cm"> * @api public</span></div><div class='line' id='LC703'><span class="cm"> */</span></div><div class='line' id='LC704'><br/></div><div class='line' id='LC705'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">emit</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">ev</span><span class="p">){</span></div><div class='line' id='LC706'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">events</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">ev</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC707'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">emit</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">arguments</span><span class="p">);</span></div><div class='line' id='LC708'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC709'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC710'><br/></div><div class='line' id='LC711'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">toArray</span><span class="p">(</span><span class="nx">arguments</span><span class="p">);</span></div><div class='line' id='LC712'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">parserType</span> <span class="o">=</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">EVENT</span><span class="p">;</span> <span class="c1">// default</span></div><div class='line' id='LC713'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">hasBin</span><span class="p">(</span><span class="nx">args</span><span class="p">))</span> <span class="p">{</span> <span class="nx">parserType</span> <span class="o">=</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">BINARY_EVENT</span><span class="p">;</span> <span class="p">}</span> <span class="c1">// binary</span></div><div class='line' id='LC714'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">packet</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">type</span><span class="o">:</span> <span class="nx">parserType</span><span class="p">,</span> <span class="nx">data</span><span class="o">:</span> <span class="nx">args</span> <span class="p">};</span></div><div class='line' id='LC715'><br/></div><div class='line' id='LC716'>&nbsp;&nbsp;<span class="c1">// event ack callback</span></div><div class='line' id='LC717'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;function&#39;</span> <span class="o">==</span> <span class="k">typeof</span> <span class="nx">args</span><span class="p">[</span><span class="nx">args</span><span class="p">.</span><span class="nx">length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">])</span> <span class="p">{</span></div><div class='line' id='LC718'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;emitting packet with ack id %d&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">ids</span><span class="p">);</span></div><div class='line' id='LC719'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">acks</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">ids</span><span class="p">]</span> <span class="o">=</span> <span class="nx">args</span><span class="p">.</span><span class="nx">pop</span><span class="p">();</span></div><div class='line' id='LC720'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">packet</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">ids</span><span class="o">++</span><span class="p">;</span></div><div class='line' id='LC721'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC722'><br/></div><div class='line' id='LC723'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connected</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC724'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packet</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC725'>&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC726'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">sendBuffer</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC727'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC728'><br/></div><div class='line' id='LC729'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC730'><span class="p">};</span></div><div class='line' id='LC731'><br/></div><div class='line' id='LC732'><span class="cm">/**</span></div><div class='line' id='LC733'><span class="cm"> * Sends a packet.</span></div><div class='line' id='LC734'><span class="cm"> *</span></div><div class='line' id='LC735'><span class="cm"> * @param {Object} packet</span></div><div class='line' id='LC736'><span class="cm"> * @api private</span></div><div class='line' id='LC737'><span class="cm"> */</span></div><div class='line' id='LC738'><br/></div><div class='line' id='LC739'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">packet</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">packet</span><span class="p">){</span></div><div class='line' id='LC740'>&nbsp;&nbsp;<span class="nx">packet</span><span class="p">.</span><span class="nx">nsp</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsp</span><span class="p">;</span></div><div class='line' id='LC741'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">io</span><span class="p">.</span><span class="nx">packet</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC742'><span class="p">};</span></div><div class='line' id='LC743'><br/></div><div class='line' id='LC744'><span class="cm">/**</span></div><div class='line' id='LC745'><span class="cm"> * &quot;Opens&quot; the socket.</span></div><div class='line' id='LC746'><span class="cm"> *</span></div><div class='line' id='LC747'><span class="cm"> * @api private</span></div><div class='line' id='LC748'><span class="cm"> */</span></div><div class='line' id='LC749'><br/></div><div class='line' id='LC750'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onopen</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC751'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;transport is open - connecting&#39;</span><span class="p">);</span></div><div class='line' id='LC752'><br/></div><div class='line' id='LC753'>&nbsp;&nbsp;<span class="c1">// write connect packet if necessary</span></div><div class='line' id='LC754'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;/&#39;</span> <span class="o">!=</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsp</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC755'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packet</span><span class="p">({</span> <span class="nx">type</span><span class="o">:</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">CONNECT</span> <span class="p">});</span></div><div class='line' id='LC756'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC757'><span class="p">};</span></div><div class='line' id='LC758'><br/></div><div class='line' id='LC759'><span class="cm">/**</span></div><div class='line' id='LC760'><span class="cm"> * Called upon engine `close`.</span></div><div class='line' id='LC761'><span class="cm"> *</span></div><div class='line' id='LC762'><span class="cm"> * @param {String} reason</span></div><div class='line' id='LC763'><span class="cm"> * @api private</span></div><div class='line' id='LC764'><span class="cm"> */</span></div><div class='line' id='LC765'><br/></div><div class='line' id='LC766'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onclose</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">reason</span><span class="p">){</span></div><div class='line' id='LC767'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;close (%s)&#39;</span><span class="p">,</span> <span class="nx">reason</span><span class="p">);</span></div><div class='line' id='LC768'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">connected</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC769'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">disconnected</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC770'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;disconnect&#39;</span><span class="p">,</span> <span class="nx">reason</span><span class="p">);</span></div><div class='line' id='LC771'><span class="p">};</span></div><div class='line' id='LC772'><br/></div><div class='line' id='LC773'><span class="cm">/**</span></div><div class='line' id='LC774'><span class="cm"> * Called with socket packet.</span></div><div class='line' id='LC775'><span class="cm"> *</span></div><div class='line' id='LC776'><span class="cm"> * @param {Object} packet</span></div><div class='line' id='LC777'><span class="cm"> * @api private</span></div><div class='line' id='LC778'><span class="cm"> */</span></div><div class='line' id='LC779'><br/></div><div class='line' id='LC780'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onpacket</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">packet</span><span class="p">){</span></div><div class='line' id='LC781'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">packet</span><span class="p">.</span><span class="nx">nsp</span> <span class="o">!=</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsp</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span></div><div class='line' id='LC782'><br/></div><div class='line' id='LC783'>&nbsp;&nbsp;<span class="k">switch</span> <span class="p">(</span><span class="nx">packet</span><span class="p">.</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC784'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">CONNECT</span><span class="o">:</span></div><div class='line' id='LC785'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onconnect</span><span class="p">();</span></div><div class='line' id='LC786'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC787'><br/></div><div class='line' id='LC788'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">EVENT</span><span class="o">:</span></div><div class='line' id='LC789'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onevent</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC790'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC791'><br/></div><div class='line' id='LC792'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">BINARY_EVENT</span><span class="o">:</span></div><div class='line' id='LC793'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onevent</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC794'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC795'><br/></div><div class='line' id='LC796'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">ACK</span><span class="o">:</span></div><div class='line' id='LC797'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onack</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC798'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC799'><br/></div><div class='line' id='LC800'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">BINARY_ACK</span><span class="o">:</span></div><div class='line' id='LC801'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onack</span><span class="p">(</span><span class="nx">packet</span><span class="p">);</span></div><div class='line' id='LC802'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC803'><br/></div><div class='line' id='LC804'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">DISCONNECT</span><span class="o">:</span></div><div class='line' id='LC805'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">ondisconnect</span><span class="p">();</span></div><div class='line' id='LC806'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC807'><br/></div><div class='line' id='LC808'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">case</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">ERROR</span><span class="o">:</span></div><div class='line' id='LC809'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="nx">packet</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span></div><div class='line' id='LC810'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">break</span><span class="p">;</span></div><div class='line' id='LC811'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC812'><span class="p">};</span></div><div class='line' id='LC813'><br/></div><div class='line' id='LC814'><span class="cm">/**</span></div><div class='line' id='LC815'><span class="cm"> * Called upon a server event.</span></div><div class='line' id='LC816'><span class="cm"> *</span></div><div class='line' id='LC817'><span class="cm"> * @param {Object} packet</span></div><div class='line' id='LC818'><span class="cm"> * @api private</span></div><div class='line' id='LC819'><span class="cm"> */</span></div><div class='line' id='LC820'><br/></div><div class='line' id='LC821'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onevent</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">packet</span><span class="p">){</span></div><div class='line' id='LC822'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">packet</span><span class="p">.</span><span class="nx">data</span> <span class="o">||</span> <span class="p">[];</span></div><div class='line' id='LC823'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;emitting event %j&#39;</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span></div><div class='line' id='LC824'><br/></div><div class='line' id='LC825'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="kc">null</span> <span class="o">!=</span> <span class="nx">packet</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC826'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;attaching ack callback to event&#39;</span><span class="p">);</span></div><div class='line' id='LC827'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">args</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">ack</span><span class="p">(</span><span class="nx">packet</span><span class="p">.</span><span class="nx">id</span><span class="p">));</span></div><div class='line' id='LC828'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC829'><br/></div><div class='line' id='LC830'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">connected</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC831'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">emit</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span></div><div class='line' id='LC832'>&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC833'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">receiveBuffer</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">args</span><span class="p">);</span></div><div class='line' id='LC834'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC835'><span class="p">};</span></div><div class='line' id='LC836'><br/></div><div class='line' id='LC837'><span class="cm">/**</span></div><div class='line' id='LC838'><span class="cm"> * Produces an ack callback to emit with an event.</span></div><div class='line' id='LC839'><span class="cm"> *</span></div><div class='line' id='LC840'><span class="cm"> * @api private</span></div><div class='line' id='LC841'><span class="cm"> */</span></div><div class='line' id='LC842'><br/></div><div class='line' id='LC843'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">ack</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">){</span></div><div class='line' id='LC844'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC845'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">sent</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC846'>&nbsp;&nbsp;<span class="k">return</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC847'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// prevent double callbacks</span></div><div class='line' id='LC848'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">sent</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span></div><div class='line' id='LC849'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">sent</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC850'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">toArray</span><span class="p">(</span><span class="nx">arguments</span><span class="p">);</span></div><div class='line' id='LC851'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;sending ack %j&#39;</span><span class="p">,</span> <span class="nx">args</span><span class="p">);</span></div><div class='line' id='LC852'><br/></div><div class='line' id='LC853'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">type</span> <span class="o">=</span> <span class="nx">hasBin</span><span class="p">(</span><span class="nx">args</span><span class="p">)</span> <span class="o">?</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">BINARY_ACK</span> <span class="o">:</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">ACK</span><span class="p">;</span></div><div class='line' id='LC854'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">packet</span><span class="p">({</span></div><div class='line' id='LC855'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">type</span><span class="o">:</span> <span class="nx">type</span><span class="p">,</span></div><div class='line' id='LC856'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">id</span><span class="o">:</span> <span class="nx">id</span><span class="p">,</span></div><div class='line' id='LC857'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">data</span><span class="o">:</span> <span class="nx">args</span></div><div class='line' id='LC858'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC859'>&nbsp;&nbsp;<span class="p">};</span></div><div class='line' id='LC860'><span class="p">};</span></div><div class='line' id='LC861'><br/></div><div class='line' id='LC862'><span class="cm">/**</span></div><div class='line' id='LC863'><span class="cm"> * Called upon a server acknowlegement.</span></div><div class='line' id='LC864'><span class="cm"> *</span></div><div class='line' id='LC865'><span class="cm"> * @param {Object} packet</span></div><div class='line' id='LC866'><span class="cm"> * @api private</span></div><div class='line' id='LC867'><span class="cm"> */</span></div><div class='line' id='LC868'><br/></div><div class='line' id='LC869'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onack</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">packet</span><span class="p">){</span></div><div class='line' id='LC870'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;calling ack %s with %j&#39;</span><span class="p">,</span> <span class="nx">packet</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="nx">packet</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span></div><div class='line' id='LC871'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">fn</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">acks</span><span class="p">[</span><span class="nx">packet</span><span class="p">.</span><span class="nx">id</span><span class="p">];</span></div><div class='line' id='LC872'>&nbsp;&nbsp;<span class="nx">fn</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">packet</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span></div><div class='line' id='LC873'>&nbsp;&nbsp;<span class="k">delete</span> <span class="k">this</span><span class="p">.</span><span class="nx">acks</span><span class="p">[</span><span class="nx">packet</span><span class="p">.</span><span class="nx">id</span><span class="p">];</span></div><div class='line' id='LC874'><span class="p">};</span></div><div class='line' id='LC875'><br/></div><div class='line' id='LC876'><span class="cm">/**</span></div><div class='line' id='LC877'><span class="cm"> * Called upon server connect.</span></div><div class='line' id='LC878'><span class="cm"> *</span></div><div class='line' id='LC879'><span class="cm"> * @api private</span></div><div class='line' id='LC880'><span class="cm"> */</span></div><div class='line' id='LC881'><br/></div><div class='line' id='LC882'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">onconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC883'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">connected</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div><div class='line' id='LC884'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">disconnected</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC885'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emit</span><span class="p">(</span><span class="s1">&#39;connect&#39;</span><span class="p">);</span></div><div class='line' id='LC886'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">emitBuffered</span><span class="p">();</span></div><div class='line' id='LC887'><span class="p">};</span></div><div class='line' id='LC888'><br/></div><div class='line' id='LC889'><span class="cm">/**</span></div><div class='line' id='LC890'><span class="cm"> * Emit buffered events (received and emitted).</span></div><div class='line' id='LC891'><span class="cm"> *</span></div><div class='line' id='LC892'><span class="cm"> * @api private</span></div><div class='line' id='LC893'><span class="cm"> */</span></div><div class='line' id='LC894'><br/></div><div class='line' id='LC895'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">emitBuffered</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC896'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">i</span><span class="p">;</span></div><div class='line' id='LC897'>&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">receiveBuffer</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC898'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">emit</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">receiveBuffer</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span></div><div class='line' id='LC899'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC900'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">receiveBuffer</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC901'><br/></div><div class='line' id='LC902'>&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">sendBuffer</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC903'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packet</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">sendBuffer</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span></div><div class='line' id='LC904'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC905'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">sendBuffer</span> <span class="o">=</span> <span class="p">[];</span></div><div class='line' id='LC906'><span class="p">};</span></div><div class='line' id='LC907'><br/></div><div class='line' id='LC908'><span class="cm">/**</span></div><div class='line' id='LC909'><span class="cm"> * Called upon server disconnect.</span></div><div class='line' id='LC910'><span class="cm"> *</span></div><div class='line' id='LC911'><span class="cm"> * @api private</span></div><div class='line' id='LC912'><span class="cm"> */</span></div><div class='line' id='LC913'><br/></div><div class='line' id='LC914'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">ondisconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC915'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;server disconnect (%s)&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsp</span><span class="p">);</span></div><div class='line' id='LC916'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">destroy</span><span class="p">();</span></div><div class='line' id='LC917'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onclose</span><span class="p">(</span><span class="s1">&#39;io server disconnect&#39;</span><span class="p">);</span></div><div class='line' id='LC918'><span class="p">};</span></div><div class='line' id='LC919'><br/></div><div class='line' id='LC920'><span class="cm">/**</span></div><div class='line' id='LC921'><span class="cm"> * Called upon forced client/server side disconnections,</span></div><div class='line' id='LC922'><span class="cm"> * this method ensures the manager stops tracking us and</span></div><div class='line' id='LC923'><span class="cm"> * that reconnections don&#39;t get triggered for this.</span></div><div class='line' id='LC924'><span class="cm"> *</span></div><div class='line' id='LC925'><span class="cm"> * @api private.</span></div><div class='line' id='LC926'><span class="cm"> */</span></div><div class='line' id='LC927'><br/></div><div class='line' id='LC928'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">destroy</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC929'>&nbsp;&nbsp;<span class="c1">// clean subscriptions to avoid reconnections</span></div><div class='line' id='LC930'>&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC931'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">subs</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">destroy</span><span class="p">();</span></div><div class='line' id='LC932'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC933'><br/></div><div class='line' id='LC934'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">io</span><span class="p">.</span><span class="nx">destroy</span><span class="p">(</span><span class="k">this</span><span class="p">);</span></div><div class='line' id='LC935'><span class="p">};</span></div><div class='line' id='LC936'><br/></div><div class='line' id='LC937'><span class="cm">/**</span></div><div class='line' id='LC938'><span class="cm"> * Disconnects the socket manually.</span></div><div class='line' id='LC939'><span class="cm"> *</span></div><div class='line' id='LC940'><span class="cm"> * @return {Socket} self</span></div><div class='line' id='LC941'><span class="cm"> * @api public</span></div><div class='line' id='LC942'><span class="cm"> */</span></div><div class='line' id='LC943'><br/></div><div class='line' id='LC944'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">close</span> <span class="o">=</span></div><div class='line' id='LC945'><span class="nx">Socket</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">disconnect</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC946'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">connected</span><span class="p">)</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC947'><br/></div><div class='line' id='LC948'>&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;performing disconnect (%s)&#39;</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">nsp</span><span class="p">);</span></div><div class='line' id='LC949'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">packet</span><span class="p">({</span> <span class="nx">type</span><span class="o">:</span> <span class="nx">parser</span><span class="p">.</span><span class="nx">DISCONNECT</span> <span class="p">});</span></div><div class='line' id='LC950'><br/></div><div class='line' id='LC951'>&nbsp;&nbsp;<span class="c1">// remove socket from pool</span></div><div class='line' id='LC952'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">destroy</span><span class="p">();</span></div><div class='line' id='LC953'><br/></div><div class='line' id='LC954'>&nbsp;&nbsp;<span class="c1">// fire events</span></div><div class='line' id='LC955'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">onclose</span><span class="p">(</span><span class="s1">&#39;io client disconnect&#39;</span><span class="p">);</span></div><div class='line' id='LC956'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC957'><span class="p">};</span></div><div class='line' id='LC958'><br/></div><div class='line' id='LC959'><span class="p">},{</span><span class="s2">&quot;./on&quot;</span><span class="o">:</span><span class="mi">4</span><span class="p">,</span><span class="s2">&quot;component-bind&quot;</span><span class="o">:</span><span class="mi">7</span><span class="p">,</span><span class="s2">&quot;component-emitter&quot;</span><span class="o">:</span><span class="mi">8</span><span class="p">,</span><span class="s2">&quot;debug&quot;</span><span class="o">:</span><span class="mi">9</span><span class="p">,</span><span class="s2">&quot;has-binary-data&quot;</span><span class="o">:</span><span class="mi">32</span><span class="p">,</span><span class="s2">&quot;indexof&quot;</span><span class="o">:</span><span class="mi">36</span><span class="p">,</span><span class="s2">&quot;socket.io-parser&quot;</span><span class="o">:</span><span class="mi">40</span><span class="p">,</span><span class="s2">&quot;to-array&quot;</span><span class="o">:</span><span class="mi">43</span><span class="p">}],</span><span class="mi">6</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC960'><span class="kd">var</span> <span class="nx">global</span><span class="o">=</span><span class="k">typeof</span> <span class="nx">self</span> <span class="o">!==</span> <span class="s2">&quot;undefined&quot;</span> <span class="o">?</span> <span class="nx">self</span> <span class="o">:</span> <span class="k">typeof</span> <span class="nb">window</span> <span class="o">!==</span> <span class="s2">&quot;undefined&quot;</span> <span class="o">?</span> <span class="nb">window</span> <span class="o">:</span> <span class="p">{};</span></div><div class='line' id='LC961'><span class="cm">/**</span></div><div class='line' id='LC962'><span class="cm"> * Module dependencies.</span></div><div class='line' id='LC963'><span class="cm"> */</span></div><div class='line' id='LC964'><br/></div><div class='line' id='LC965'><span class="kd">var</span> <span class="nx">parseuri</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;parseuri&#39;</span><span class="p">);</span></div><div class='line' id='LC966'><span class="kd">var</span> <span class="nx">debug</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;debug&#39;</span><span class="p">)(</span><span class="s1">&#39;socket.io-client:url&#39;</span><span class="p">);</span></div><div class='line' id='LC967'><br/></div><div class='line' id='LC968'><span class="cm">/**</span></div><div class='line' id='LC969'><span class="cm"> * Module exports.</span></div><div class='line' id='LC970'><span class="cm"> */</span></div><div class='line' id='LC971'><br/></div><div class='line' id='LC972'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">url</span><span class="p">;</span></div><div class='line' id='LC973'><br/></div><div class='line' id='LC974'><span class="cm">/**</span></div><div class='line' id='LC975'><span class="cm"> * URL parser.</span></div><div class='line' id='LC976'><span class="cm"> *</span></div><div class='line' id='LC977'><span class="cm"> * @param {String} url</span></div><div class='line' id='LC978'><span class="cm"> * @param {Object} An object meant to mimic window.location.</span></div><div class='line' id='LC979'><span class="cm"> *                 Defaults to window.location.</span></div><div class='line' id='LC980'><span class="cm"> * @api public</span></div><div class='line' id='LC981'><span class="cm"> */</span></div><div class='line' id='LC982'><br/></div><div class='line' id='LC983'><span class="kd">function</span> <span class="nx">url</span><span class="p">(</span><span class="nx">uri</span><span class="p">,</span> <span class="nx">loc</span><span class="p">){</span></div><div class='line' id='LC984'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">obj</span> <span class="o">=</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC985'><br/></div><div class='line' id='LC986'>&nbsp;&nbsp;<span class="c1">// default to window.location</span></div><div class='line' id='LC987'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">loc</span> <span class="o">=</span> <span class="nx">loc</span> <span class="o">||</span> <span class="nx">global</span><span class="p">.</span><span class="nx">location</span><span class="p">;</span></div><div class='line' id='LC988'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="kc">null</span> <span class="o">==</span> <span class="nx">uri</span><span class="p">)</span> <span class="nx">uri</span> <span class="o">=</span> <span class="nx">loc</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">+</span> <span class="s1">&#39;//&#39;</span> <span class="o">+</span> <span class="nx">loc</span><span class="p">.</span><span class="nx">hostname</span><span class="p">;</span></div><div class='line' id='LC989'><br/></div><div class='line' id='LC990'>&nbsp;&nbsp;<span class="c1">// relative path support</span></div><div class='line' id='LC991'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;string&#39;</span> <span class="o">==</span> <span class="k">typeof</span> <span class="nx">uri</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC992'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;/&#39;</span> <span class="o">==</span> <span class="nx">uri</span><span class="p">.</span><span class="nx">charAt</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC993'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;undefined&#39;</span> <span class="o">!=</span> <span class="k">typeof</span> <span class="nx">loc</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC994'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">uri</span> <span class="o">=</span> <span class="nx">loc</span><span class="p">.</span><span class="nx">hostname</span> <span class="o">+</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC995'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC996'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC997'><br/></div><div class='line' id='LC998'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="sr">/^(https?|wss?):\/\//</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">uri</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC999'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;protocol-less url %s&#39;</span><span class="p">,</span> <span class="nx">uri</span><span class="p">);</span></div><div class='line' id='LC1000'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;undefined&#39;</span> <span class="o">!=</span> <span class="k">typeof</span> <span class="nx">loc</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC1001'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">uri</span> <span class="o">=</span> <span class="nx">loc</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">+</span> <span class="s1">&#39;//&#39;</span> <span class="o">+</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC1002'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></div><div class='line' id='LC1003'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">uri</span> <span class="o">=</span> <span class="s1">&#39;https://&#39;</span> <span class="o">+</span> <span class="nx">uri</span><span class="p">;</span></div><div class='line' id='LC1004'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1005'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1006'><br/></div><div class='line' id='LC1007'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">// parse</span></div><div class='line' id='LC1008'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">debug</span><span class="p">(</span><span class="s1">&#39;parse %s&#39;</span><span class="p">,</span> <span class="nx">uri</span><span class="p">);</span></div><div class='line' id='LC1009'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">obj</span> <span class="o">=</span> <span class="nx">parseuri</span><span class="p">(</span><span class="nx">uri</span><span class="p">);</span></div><div class='line' id='LC1010'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1011'><br/></div><div class='line' id='LC1012'>&nbsp;&nbsp;<span class="c1">// make sure we treat `localhost:80` and `localhost` equally</span></div><div class='line' id='LC1013'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">obj</span><span class="p">.</span><span class="nx">port</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC1014'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="sr">/^(http|ws)$/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">protocol</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC1015'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">port</span> <span class="o">=</span> <span class="s1">&#39;80&#39;</span><span class="p">;</span></div><div class='line' id='LC1016'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1017'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="sr">/^(http|ws)s$/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">protocol</span><span class="p">))</span> <span class="p">{</span></div><div class='line' id='LC1018'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">port</span> <span class="o">=</span> <span class="s1">&#39;443&#39;</span><span class="p">;</span></div><div class='line' id='LC1019'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1020'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1021'><br/></div><div class='line' id='LC1022'>&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">path</span> <span class="o">||</span> <span class="s1">&#39;/&#39;</span><span class="p">;</span></div><div class='line' id='LC1023'><br/></div><div class='line' id='LC1024'>&nbsp;&nbsp;<span class="c1">// define unique id</span></div><div class='line' id='LC1025'>&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">+</span> <span class="s1">&#39;://&#39;</span> <span class="o">+</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">host</span> <span class="o">+</span> <span class="s1">&#39;:&#39;</span> <span class="o">+</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">port</span><span class="p">;</span></div><div class='line' id='LC1026'>&nbsp;&nbsp;<span class="c1">// define href</span></div><div class='line' id='LC1027'>&nbsp;&nbsp;<span class="nx">obj</span><span class="p">.</span><span class="nx">href</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">+</span> <span class="s1">&#39;://&#39;</span> <span class="o">+</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">host</span> <span class="o">+</span> <span class="p">(</span><span class="nx">loc</span> <span class="o">&amp;&amp;</span> <span class="nx">loc</span><span class="p">.</span><span class="nx">port</span> <span class="o">==</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">port</span> <span class="o">?</span> <span class="s1">&#39;&#39;</span> <span class="o">:</span> <span class="p">(</span><span class="s1">&#39;:&#39;</span> <span class="o">+</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">port</span><span class="p">));</span></div><div class='line' id='LC1028'><br/></div><div class='line' id='LC1029'>&nbsp;&nbsp;<span class="k">return</span> <span class="nx">obj</span><span class="p">;</span></div><div class='line' id='LC1030'><span class="p">}</span></div><div class='line' id='LC1031'><br/></div><div class='line' id='LC1032'><span class="p">},{</span><span class="s2">&quot;debug&quot;</span><span class="o">:</span><span class="mi">9</span><span class="p">,</span><span class="s2">&quot;parseuri&quot;</span><span class="o">:</span><span class="mi">38</span><span class="p">}],</span><span class="mi">7</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC1033'><span class="cm">/**</span></div><div class='line' id='LC1034'><span class="cm"> * Slice reference.</span></div><div class='line' id='LC1035'><span class="cm"> */</span></div><div class='line' id='LC1036'><br/></div><div class='line' id='LC1037'><span class="kd">var</span> <span class="nx">slice</span> <span class="o">=</span> <span class="p">[].</span><span class="nx">slice</span><span class="p">;</span></div><div class='line' id='LC1038'><br/></div><div class='line' id='LC1039'><span class="cm">/**</span></div><div class='line' id='LC1040'><span class="cm"> * Bind `obj` to `fn`.</span></div><div class='line' id='LC1041'><span class="cm"> *</span></div><div class='line' id='LC1042'><span class="cm"> * @param {Object} obj</span></div><div class='line' id='LC1043'><span class="cm"> * @param {Function|String} fn or string</span></div><div class='line' id='LC1044'><span class="cm"> * @return {Function}</span></div><div class='line' id='LC1045'><span class="cm"> * @api public</span></div><div class='line' id='LC1046'><span class="cm"> */</span></div><div class='line' id='LC1047'><br/></div><div class='line' id='LC1048'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">fn</span><span class="p">){</span></div><div class='line' id='LC1049'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;string&#39;</span> <span class="o">==</span> <span class="k">typeof</span> <span class="nx">fn</span><span class="p">)</span> <span class="nx">fn</span> <span class="o">=</span> <span class="nx">obj</span><span class="p">[</span><span class="nx">fn</span><span class="p">];</span></div><div class='line' id='LC1050'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;function&#39;</span> <span class="o">!=</span> <span class="k">typeof</span> <span class="nx">fn</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s1">&#39;bind() requires a function&#39;</span><span class="p">);</span></div><div class='line' id='LC1051'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span></div><div class='line' id='LC1052'>&nbsp;&nbsp;<span class="k">return</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC1053'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="nx">fn</span><span class="p">.</span><span class="nx">apply</span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">args</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">)));</span></div><div class='line' id='LC1054'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1055'><span class="p">};</span></div><div class='line' id='LC1056'><br/></div><div class='line' id='LC1057'><span class="p">},{}],</span><span class="mi">8</span><span class="o">:</span><span class="p">[</span><span class="kd">function</span><span class="p">(</span><span class="nx">require</span><span class="p">,</span><span class="nx">module</span><span class="p">,</span><span class="nx">exports</span><span class="p">){</span></div><div class='line' id='LC1058'><br/></div><div class='line' id='LC1059'><span class="cm">/**</span></div><div class='line' id='LC1060'><span class="cm"> * Expose `Emitter`.</span></div><div class='line' id='LC1061'><span class="cm"> */</span></div><div class='line' id='LC1062'><br/></div><div class='line' id='LC1063'><span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">Emitter</span><span class="p">;</span></div><div class='line' id='LC1064'><br/></div><div class='line' id='LC1065'><span class="cm">/**</span></div><div class='line' id='LC1066'><span class="cm"> * Initialize a new `Emitter`.</span></div><div class='line' id='LC1067'><span class="cm"> *</span></div><div class='line' id='LC1068'><span class="cm"> * @api public</span></div><div class='line' id='LC1069'><span class="cm"> */</span></div><div class='line' id='LC1070'><br/></div><div class='line' id='LC1071'><span class="kd">function</span> <span class="nx">Emitter</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC1072'>&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="k">return</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">obj</span><span class="p">);</span></div><div class='line' id='LC1073'><span class="p">};</span></div><div class='line' id='LC1074'><br/></div><div class='line' id='LC1075'><span class="cm">/**</span></div><div class='line' id='LC1076'><span class="cm"> * Mixin the emitter properties.</span></div><div class='line' id='LC1077'><span class="cm"> *</span></div><div class='line' id='LC1078'><span class="cm"> * @param {Object} obj</span></div><div class='line' id='LC1079'><span class="cm"> * @return {Object}</span></div><div class='line' id='LC1080'><span class="cm"> * @api private</span></div><div class='line' id='LC1081'><span class="cm"> */</span></div><div class='line' id='LC1082'><br/></div><div class='line' id='LC1083'><span class="kd">function</span> <span class="nx">mixin</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC1084'>&nbsp;&nbsp;<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">key</span> <span class="k">in</span> <span class="nx">Emitter</span><span class="p">.</span><span class="nx">prototype</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC1085'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">obj</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nx">Emitter</span><span class="p">.</span><span class="nx">prototype</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span></div><div class='line' id='LC1086'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC1087'>&nbsp;&nbsp;<span class="k">return</span> <span class="nx">obj</span><span class="p">;</span></div><div class='line' id='LC1088'><span class="p">}</span></div><div class='line' id='LC1089'><br/></div><div class='line' id='LC1090'><span class="cm">/**</span></div><div class='line' id='LC1091'><span class="cm"> * Listen on the given `event` with `fn`.</span></div><div class='line' id='LC1092'><span class="cm"> *</span></div><div class='line' id='LC1093'><span class="cm"> * @param {String} event</span></div><div class='line' id='LC1094'><span class="cm"> * @param {Function} fn</span></div><div class='line' id='LC1095'><span class="cm"> * @return {Emitter}</span></div><div class='line' id='LC1096'><span class="cm"> * @api public</span></div><div class='line' id='LC1097'><span class="cm"> */</span></div><div class='line' id='LC1098'><br/></div><div class='line' id='LC1099'><span class="nx">Emitter</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">on</span> <span class="o">=</span></div><div class='line' id='LC1100'><span class="nx">Emitter</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">addEventListener</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="nx">fn</span><span class="p">){</span></div><div class='line' id='LC1101'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span> <span class="o">||</span> <span class="p">{};</span></div><div class='line' id='LC1102'>&nbsp;&nbsp;<span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span><span class="p">[</span><span class="nx">event</span><span class="p">]</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span><span class="p">[</span><span class="nx">event</span><span class="p">]</span> <span class="o">||</span> <span class="p">[])</span></div><div class='line' id='LC1103'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">fn</span><span class="p">);</span></div><div class='line' id='LC1104'>&nbsp;&nbsp;<span class="k">return</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC1105'><span class="p">};</span></div><div class='line' id='LC1106'><br/></div><div class='line' id='LC1107'><span class="cm">/**</span></div><div class='line' id='LC1108'><span class="cm"> * Adds an `event` listener that will be invoked a single</span></div><div class='line' id='LC1109'><span class="cm"> * time then automatically removed.</span></div><div class='line' id='LC1110'><span class="cm"> *</span></div><div class='line' id='LC1111'><span class="cm"> * @param {String} event</span></div><div class='line' id='LC1112'><span class="cm"> * @param {Function} fn</span></div><div class='line' id='LC1113'><span class="cm"> * @return {Emitter}</span></div><div class='line' id='LC1114'><span class="cm"> * @api public</span></div><div class='line' id='LC1115'><span class="cm"> */</span></div><div class='line' id='LC1116'><br/></div><div class='line' id='LC1117'><span class="nx">Emitter</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">once</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="nx">fn</span><span class="p">){</span></div><div class='line' id='LC1118'>&nbsp;&nbsp;<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span></div><div class='line' id='LC1119'>&nbsp;&nbsp;<span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_callbacks</span> <span class="o">||</span> <span class="p">{};</span></div><div class='line' id='LC1120'><br/></div><div class='line' id='LC1121'>&nbsp;&nbsp;<span class="kd">function</span> <span class="nx">on</span><span class="p">()</span> <span class="p">{</span></div><div class='line' id='LC1122'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">self</span><span class="p">.</span><span class="nx">
socket.h https://github.com/shehperd/Espruino.git | C++ Header | 462 lines
4//! \brief SOCKET APIs Header file.
5//! \details SOCKET APIs like as berkeley socket api. 
6//! \version 1.0.0
42/**
43 * @defgroup WIZnet_socket_APIs 1. WIZnet socket APIs
44 * @brief WIZnet socket APIs are based on Berkeley socket APIs,  thus it has much similar name and interface.
61 * There are @b bind() and @b accept() functions in @b Berkeley SOCKET API but,
62 * not in @b WIZnet SOCKET API. Because socket() of WIZnet is not only creating a SOCKET but also binding a local port number,
63 * and listen() of WIZnet is not only listening to connection request from client but also accepting the connection request. \n
73 * If there're many listen SOCKET with same listen port number and a client requests a connection,
74 * the SOCKET which has the smallest SOCKET number accepts the request and is changed as communication SOCKET. \n
75 * Following figure shows network flow diagram by WIZnet SOCKET API.
362{
363   SO_FLAG,           ///< Valid only in getsockopt(), For set flag of socket refer to <I>flag</I> in @ref socket().
364   SO_TTL,              ///< Set/Get TTL. @ref Sn_TTL  ( @ref setSn_TTL(), @ref getSn_TTL() )
socket.io.js https://github.com/eheb/socket.io.git | JavaScript | 1,384 lines
187        request(srv)
188        .get('/socket.io/socket.io.js')
189        .end(function(err, res){
422          sio.of('/news', function(socket){
423            expect(socket).to.be.a(Socket);
424            --total || done();
1244  describe('middleware', function(done){
1245    var Socket = require('../lib/socket');
1246
1251      sio.use(function(socket, next){
1252        expect(socket).to.be.a(Socket);
1253        run++;
1256      sio.use(function(socket, next){
1257        expect(socket).to.be.a(Socket);
1258        run++;
socket.io.js https://github.com/TakumiBaba/callForwardingExtension.git | JavaScript | 2,599 lines
96
97    socket = socket || io.sockets[uuri];
98
1455   *
1456   * @param {Socket} socket The socket instance that needs a transport
1457   * @param {Function} fn The callback
2010  function SocketNamespace (socket, name) {
2011    this.socket = socket;
2012    this.name = name || '';
2040  SocketNamespace.prototype.of = function () {
2041    return this.socket.of.apply(this.socket, arguments);
2042  };
2572   *
2573   * @param {Socket} socket The socket instance that needs a transport
2574   * @param {Function} fn The callback
socket.io.js https://github.com/victorferreira/tv.js.git | JavaScript | 3,327 lines
1292    // that we don't reset the timeout on an explicitly disconnected connection.
1293    if (this.socket.connected || this.socket.connecting || this.socket.reconnecting) {
1294      this.setCloseTimeout();
1478   *
1479   * @param {Socket} socket The socket instance that needs a transport
1480   * @param {Function} fn The callback
2690          usesXDomReq = (global.XDomainRequest && request instanceof XDomainRequest),
2691          socketProtocol = (socket && socket.options && socket.options.secure ? 'https:' : 'http:'),
2692          isXProtocol = (global.location && socketProtocol != global.location.protocol);
3040   *
3041   * @param {Socket} socket The socket instance that needs a transport
3042   * @param {Function} fn The callback
3273   *
3274   * @param {Socket} socket The socket instance that needs a transport
3275   * @param {Function} fn The callback
socket.c https://github.com/flexiant/extility-guacamole-server.git | C | 321 lines
67
68    guac_socket* socket = malloc(sizeof(guac_socket));
69
101
102void guac_socket_close(guac_socket* socket) {
103    guac_socket_flush(socket);
129
130ssize_t guac_socket_write_int(guac_socket* socket, int64_t i) {
131
150
151            retval = __guac_socket_write(socket, __out_buf, socket->__written);
152
257    if (socket->__written > 0) {
258        retval = __guac_socket_write(socket, socket->__out_buf, socket->__written);
259        if (retval < 0)
socket.io-0.9.10.js https://github.com/ADAIN/mod-socket-io.git | JavaScript | 3,887 lines
1478		 *
1479		 * @param {Socket} socket The socket instance that needs a transport
1480		 * @param {Function} fn The callback
2940			if (!window.WEB_SOCKET_SWF_LOCATION) {
2941				console.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");
2942				return;
3261						usesXDomReq = (global.XDomainRequest && request instanceof XDomainRequest),
3262						socketProtocol = (socket && socket.options && socket.options.secure ? 'https:' : 'http:'),
3263						isXProtocol = (socketProtocol != global.location.protocol);
3432		 *
3433		 * @param {Socket} socket The socket instance that needs a transport
3434		 * @param {Function} fn The callback
3665		 *
3666		 * @param {Socket} socket The socket instance that needs a transport
3667		 * @param {Function} fn The callback
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21