var HANDSHAKE_TIMEOUT = 5000
169654
function Client (opts) {
  var self = this

  typeforce({
    url: 'String',
    otrKey: 'DSA',
    // byRootHash: 'Function',
    instanceTag: '?String',
    autoconnect: '?Boolean' // defaults to true
  }, opts)

  EventEmitter.call(this)
  this.setMaxListeners(0)

  this._url = parseURL(opts.url)
  this._autoconnect = opts.autoconnect !== false
  this._onmessage = this._onmessage.bind(this)
  this._sessions = {}
  this._otrKey = opts.otrKey
  this._fingerprint = opts.otrKey.fingerprint()
  this._connected = false
  this._instanceTag = opts.instanceTag
  this._backoff = backoff.exponential({ initialDelay: 100 })
  if (this._autoconnect) this.connect()
}
1009310
function send(conn,schemaName,json,byteLength){

        var buffer = micro.toBinary(json, schemaName,byteLength);

        if (FAKE_LATENCY){
            setTimeout(function(){
                conn.sendBytes(buffer);
            },FAKE_LATENCY);
        }else{
            conn.sendBytes(buffer);
        }
    }
28317
function handleRejections (runHooks, timeout) {
    process.on('unhandledRejection', err => onUncaught(err, runHooks, timeout));
}
246359
function set_timeout($timeout_recv, $timeout_send)
    {
        $_timeout_recv_sec = (int)$timeout_recv;
        $_timeout_send_sec = (int)$timeout_send;

        $this->timeout_recv = $timeout_recv;
        $this->timeout_send = $timeout_send;

        $_timeout_recv = array(
            'sec' => $_timeout_recv_sec,
            'usec' => (int)(($timeout_recv - $_timeout_recv_sec) * 1000 * 1000)
        );
        $_timeout_send = array(
            'sec' => $_timeout_send_sec,
            'usec' => (int)(($timeout_send - $_timeout_send_sec) * 1000 * 1000)
        );

        $this->setopt(SO_RCVTIMEO, $_timeout_recv);
        $this->setopt(SO_SNDTIMEO, $_timeout_send);
    }
802733
function () {
		var freq = new Int32Array(hands.length);
		var start = Date.now();
		for (var c1 = 1; c1 <= deckSize; c1++) {
			var r1 = evaluator[deckSize + c1 + 1];
			for (var c2 = c1 + 1; c2 <= deckSize; c2++) {
				var r2 = evaluator[r1 + c2];
				for (var c3 = c2 + 1; c3 <= deckSize; c3++) {
					var r3 = evaluator[r2 + c3];
					for (var c4 = c3 + 1; c4 <= deckSize; c4++) {
						var r4 = evaluator[r3 + c4];
						for (var c5 = c4 + 1; c5 <= deckSize; c5++) {
							var r5 = evaluator[r4 + c5];
							for (var c6 = c5 + 1; c6 <= deckSize; c6++) {
								var r6 = evaluator[r5 + c6];
								for (var c7 = c6 + 1; c7 <= deckSize; c7++) {
									var r7 = evaluator[r6 + c7];
									freq[r7 >> 12]++;
		}	}	}	}	}	}	}
		var finish = Date.now();
		var total = 0;
		for (var key = 0; key < hands.length; key++) {
			total += freq[key];
			console.log(hands[key] + ': ' + freq[key]);
		}
		console.log('Total: ' + total);
		console.log((finish - start) + 'ms');
	}
1116792
function ConnectionTimeoutError(timeout) {
    Error.call(this);
    Error.captureStackTrace(this, this.constructor);
    this.message = 'connection timed out';

    if (timeout) {
        this.message += '. timeout = ' + timeout + ' ms';
    }

    this.name = 'ConnectionTimeoutError';
}
260727
@SuppressWarnings("unchecked")
	protected void _handshake() throws IOException {
		// do connection handshake

		PyroSerializer ser = PyroSerializer.getFor(Config.SERIALIZER);
		Map<String, Object> handshakedata = new HashMap<String, Object>();
		handshakedata.put("handshake", pyroHandshake);
		if(Config.METADATA)
			handshakedata.put("object", objectid);
		byte[] data = ser.serializeData(handshakedata);
		int flags = Config.METADATA? Message.FLAGS_META_ON_CONNECT : 0;
		Message msg = new Message(Message.MSG_CONNECT, data, ser.getSerializerId(), flags, sequenceNr, annotations(), pyroHmacKey);
		IOUtil.send(sock_out, msg.to_bytes());
		if(Config.MSG_TRACE_DIR!=null) {
			Message.TraceMessageSend(sequenceNr, msg.get_header_bytes(), msg.get_annotations_bytes(), msg.data);
		}

		// process handshake response
		msg = Message.recv(sock_in, new int[]{Message.MSG_CONNECTOK, Message.MSG_CONNECTFAIL}, pyroHmacKey);
		responseAnnotations(msg.annotations, msg.type);
		Object handshake_response = "?";
		if(msg.data!=null) {
			if((msg.flags & Message.FLAGS_COMPRESSED) != 0) {
				_decompressMessageData(msg);
			}
			try {
				ser = PyroSerializer.getFor(msg.serializer_id);
				handshake_response = ser.deserializeData(msg.data);
			} catch (Exception x) {
				msg.type=Message.MSG_CONNECTFAIL;
				handshake_response = "<not available because unsupported serialization format>";
			}
		}
		if(msg.type==Message.MSG_CONNECTOK) {
			if((msg.flags & Message.FLAGS_META_ON_CONNECT) != 0) {
				HashMap<String, Object> response_dict = (HashMap<String, Object>)handshake_response;
				HashMap<String, Object> metadata = (HashMap<String, Object>) response_dict.get("meta");
				_processMetadata(metadata);
				handshake_response = response_dict.get("handshake");
				try {
					validateHandshake(handshake_response);
				} catch (IOException x) {
					close();
					throw x;
				}
			}
		} else if (msg.type==Message.MSG_CONNECTFAIL) {
			close();
			throw new PyroException("connection rejected, reason: "+handshake_response);
		} else {
			close();
			throw new PyroException("connect: invalid msg type "+msg.type+" received");
		}
	}
1298891
function waitTimeoutNotice() {
        var hangModules = [];
        var missModules = [];
        var missModulesMap = {};
        var hasError;

        for ( var id in modModules ) {
            if ( !modIsDefined( id ) ) {
                hasError = 1;
                hangModules.push( id );
            }

            each(
                modModules[ id ].depMs || [],
                function ( dep ) {
                    var depId = dep.absId;
                    if ( !modModules[ depId ] && !missModulesMap[ depId ] ) {
                        hasError = 1;
                        missModules.push( depId );
                        missModulesMap[ depId ] = 1;
                    }
                }
            );
        }

        if ( hasError ) {
            throw new Error( '[MODULE_TIMEOUT]Hang( '
                + ( hangModules.join( ', ' ) || 'none' )
                + ' ) Miss( '
                + ( missModules.join( ', ' ) || 'none' )
                + ' )'
            );
        }
    }
1196699
function() {
	this.ENL_PORT = 3610;
	this.BAUD = 115200;
	this.SERIAL_SEND_INTERVAL = 500; // ms

	this.initialized = false;
	this.dataCallback = function(){};
	this.sentCallback = function(){};
	this.dataCallbackSerial = function(){};
	this.sentCallbackSerial = function(){};

	this.serialCallback = function(){};
	this.params = {};
	this.port = null;
	this.device = null;
	this.is_discovering = false;
	this.discovery_timer_id = null;
	this.response_buffer = null;
	this.response_text = '';

	this.mAdapter = null;
}
137216
private static RLSSuspendToken suspendRLS(int timeout) throws RLSTimeoutRangeException
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "suspendRLS", new Integer(timeout));
        
        if (timeout < 0 || timeout > 1000000000)
        {
             if (tc.isEventEnabled()) Tr.event(tc, "Timeout value is out of range - throwing RLSTimeoutRangeException", new Integer(timeout));
             if (tc.isEntryEnabled()) Tr.exit(tc, "suspend", "RLSTimeoutRangeException");
        	throw new RLSTimeoutRangeException();
        }
        
        RLSSuspendToken token = null;
        
        synchronized(SUSPEND_LOCK)
        {
        	if(!Configuration._isSnapshotSafe)
        	{
        		// If the server is not configured to be snapshot safe
        		// then we should put out a warning message
        		Tr.warning(tc, "CWRLS0020_SNAPSHOT_SAFE");
        	}
        	
            // Notify the token manager that the RLS has been called to suspend
            token = _tokenManager.registerSuspend(timeout);
            
            Tr.info(tc, "CWRLS0001_SUSPEND_RLS", token);
                
            // RLS has not already been suspended
            // Set suspended flag true
            _isSuspended = true;
        }
        
        if (tc.isEntryEnabled()) Tr.exit(tc, "suspendRLS", token);
        
        // Return the RLSSuspendToken
        return token;
    }
497454
private SSLEngineResult doHandshake(boolean async) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "doHandshake");
        }

        SSLEngineResult sslResult;
        // Line up all the buffers needed for the SSL handshake. Temporary so
        // use indirect allocation for speed.
        int appSize = getConnLink().getAppBufferSize();
        int packetSize = getConnLink().getPacketBufferSize();
        WsByteBuffer localNetBuffer = SSLUtils.allocateByteBuffer(packetSize, true);
        WsByteBuffer decryptedNetBuffer = SSLUtils.allocateByteBuffer(appSize, false);
        WsByteBuffer encryptedAppBuffer = SSLUtils.allocateByteBuffer(packetSize, true);
        // Callback to be used if the request is async.
        MyHandshakeCompletedCallback handshakeCallback = null;
        if (async) {
            handshakeCallback = new MyHandshakeCompletedCallback(this, callback, localNetBuffer, decryptedNetBuffer, encryptedAppBuffer);
        }

        try {
            // Do the SSL handshake. Note, if synchronous the handshakeCallback is null.
            sslResult = SSLUtils.handleHandshake(
                                                 getConnLink(),
                                                 localNetBuffer,
                                                 decryptedNetBuffer,
                                                 encryptedAppBuffer,
                                                 null,
                                                 handshakeCallback,
                                                 false);
        } catch (IOException e) {
            // Release buffers used in the handshake.
            localNetBuffer.release();
            localNetBuffer = null;
            decryptedNetBuffer.release();
            decryptedNetBuffer = null;
            encryptedAppBuffer.release();
            encryptedAppBuffer = null;
            throw e;
        }
        if (sslResult != null) {
            // Handshake was done synchronously.
            // Release buffers used in the handshake.
            localNetBuffer.release();
            localNetBuffer = null;
            decryptedNetBuffer.release();
            decryptedNetBuffer = null;
            encryptedAppBuffer.release();
            encryptedAppBuffer = null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "doHandshake");
        }
        return sslResult;
    }
330959
def _timeout_handler(self, signum, frame):
        
        msgfmt = 'plugin timed out after {0} seconds'
        self.exit(code=self._timeout_code,
                  message=msgfmt.format(self._timeout_delay))
145009
public static Function<RSocket, RSocket> timeout(Duration timeout) {
    return source ->
        new RSocketProxy(source) {
          @Override
          public Mono<Void> fireAndForget(Payload payload) {
            return source.fireAndForget(payload).timeout(timeout);
          }

          @Override
          public Mono<Payload> requestResponse(Payload payload) {
            return source.requestResponse(payload).timeout(timeout);
          }

          @Override
          public Flux<Payload> requestStream(Payload payload) {
            return source.requestStream(payload).timeout(timeout);
          }

          @Override
          public Flux<Payload> requestChannel(Publisher<Payload> payloads) {
            return source.requestChannel(payloads).timeout(timeout);
          }

          @Override
          public Mono<Void> metadataPush(Payload payload) {
            return source.metadataPush(payload).timeout(timeout);
          }
        };
  }
1343506
function (connectionUrl) {
        var self = ortc;

        if (self.sockjs == null) {
            if (navigator && navigator.userAgent && navigator.userAgent.indexOf('PlayStation Vita') >= 0) {
                protocol = 'jsonp-polling';
            }

            self.sockjs = new SockJS(connectionUrl + '/broadcast', protocol);

            // Timeout to receive the validated message
            if(!self.sslFallback){
                var validateTimeoutTime = 5000;
                self.validatedTimeoutId = setTimeout(function () {
                    self.sslFallback = true;
                    stopReconnectProcess();
                    disconnectSocket();

                    invalidConnection = true;
                    retryingWithSsl = true;

                    if(connectionUrl.indexOf('https://') >= 0) {
                        // We are already using SSL, try streaming
                        protocol = "xhr-streaming";
                    } else {
                        protocol = undefined;    
                    }                    

                    changeUrlSsl();
                }, validateTimeoutTime);
            } else if (!self.xhrStreamingFallback) {
                // The SSL fallback failed. Try xhr-streaming

                var validateSslTimeoutTime = 5000;
                self.validatedTimeoutId = setTimeout(function () {
                    self.xhrStreamingFallback = true;
                    stopReconnectProcess();
                    disconnectSocket();

                    invalidConnection = true;
                    retryingWithSsl = true;
                    protocol = "xhr-streaming";
                    
                }, validateSslTimeoutTime);
            }



            // Connect handler
            self.sockjs.onopen = function () {
                protocol = self.sockjs.protocol;

                // Update last keep alive time
                lastKeepAlive = new Date().getTime();

                // If is a reconnect do not count session
                if (alreadyConnectedFirstTime) {
                    sessionId = '';
                }
                else {
                    // Read session cookie
                    sessionId = readCookie(sessionCookieName + self.appKey + '-s');

                    if (!sessionId) {
                        // Read expiration cookie
                        sessionId = readCookie(sessionCookieName + self.appKey);

                        if (!sessionId) {
                            sessionId = generateId(16);
                        }

                        // Create session cookie
                        createSessionCookie(sessionCookieName + self.appKey + '-s', sessionId);

                        // Check if session cookie was created
                        if (!readCookie(sessionCookieName + self.appKey + '-s')) {
                            sessionId = '';
                        }
                    }
                }

                var heartbeatDetails = heartbeatActive ? ';' + self.getHeartbeatTime() + ';' + self.getHeartbeatFails() + ';' : '';

                self.sockjs.send('validate;' + self.appKey + ';' + self.authToken + ';' + (announcementSubChannel ? announcementSubChannel : '') + ';' + sessionId + ';' + connectionMetadata + heartbeatDetails);

            };

            // Disconnect handler
            self.sockjs.onclose = function (e) {
                // e.code=1000 - e.reason=Normal closure
                // e.code=1006 - e.reason=WebSocket connection broken
                // e.code=2000 - e.reason=All transports failed
                stopHeartBeatInterval(ortc);

                if (ortc.sockjs != null) {
                    ortc.sockjs.close();
                    ortc.sockjs = null;
                }

                // Clear user permissions
                userPerms = null;

                if (e.code != 1000) {
                    if (isConnected) {
                        isConnected = false;
                        isConnecting = false;
                        protocol = undefined;

                        delegateDisconnectedCallback(self);
                    }

                    if (!stopReconnecting) {
                        if (!reconnectStartedAt || (reconnectStartedAt + connectionTimeout < new Date().getTime())) {
                            reconnectSocket();
                        }
                    }
                }
                else {
                    if (!invalidConnection) {
                        isConnected = false;
                        isConnecting = false;
                        protocol = undefined;

                        delegateDisconnectedCallback(self);
                    }
                }

                if (retryingWithSsl) {
                    self.connect(self.appKey, self.authToken);
                    retryingWithSsl = false;
                }

                invalidConnection = false;
            };

            // Receive handler
            self.sockjs.onmessage = function (e) {
                // Update last keep alive time
                lastKeepAlive = new Date().getTime();

                var data = e.data;
                var channel = data.ch;
                var message = data.m;
                var filtered = data.f;
                var seqId = data.s;

                // Multi part
                var regexPattern = /^(\w[^_]*)_{1}(\d*)-{1}(\d*)_{1}([\s\S.]*)$/;
                var match = regexPattern.exec(message);

                var messageId = null;
                var messageCurrentPart = 1;
                var messageTotalPart = 1;
                var lastPart = false;

                if (match && match.length > 0) {
                    if (match[1]) {
                        messageId = match[1];
                    }
                    if (match[2]) {
                        messageCurrentPart = match[2];
                    }
                    if (match[3]) {
                        messageTotalPart = match[3];
                    }
                    if (match[4]) {
                        message = match[4];
                    }
                }

                if (messageId) {
                    if (!messagesBuffer[messageId]) {
                        messagesBuffer[messageId] = {};
                    }

                    messagesBuffer[messageId][messageCurrentPart] = message;

                    if (countKeys(messagesBuffer[messageId]) == messageTotalPart) {
                        lastPart = true;
                    }
                }
                else {
                    lastPart = true;
                }

                if (lastPart) {
                    if (messageId) {
                        message = "";

                        for (var i = 1; i <= messageTotalPart; i++) {
                            message += messagesBuffer[messageId][i];

                            delete messagesBuffer[messageId][i];
                        }

                        delete messagesBuffer[messageId];
                    }

                    delegateMessagesCallback(self, channel, filtered, message, seqId);
                }

                // send acknowledge
                if(messageId && seqId != null) {
                    var haveAllParts = lastPart ? "1" : "0";
                    self.sockjs.send('ack;' + self.appKey + ';' + channel + ';' + messageId + ';' + seqId + ';' + haveAllParts);
                }
            };

            self.sockjs.onortcsubscribed = function (e) {
                lastKeepAlive = new Date().getTime();

                var channel = e.data;

                if (subscribedChannels[channel]) {
                    subscribedChannels[channel].isSubscribing = false;
                    subscribedChannels[channel].isSubscribed = true;
                }

                delegateSubscribedCallback(self, channel)
            };

            self.sockjs.onortcunsubscribed = function (e) {
                lastKeepAlive = new Date().getTime();

                var channel = e.data;
                delegateUnsubscribedCallback(self, channel)
            };

            self.sockjs.onheartbeat = function () {
                lastKeepAlive = new Date().getTime();
            };

            self.sockjs.onortcvalidated = function (e) {
                var sessionExpirationTime = 30;

                if (e.data) {
                    userPerms = e.data;
                }

                if (e.set) {
                    sessionExpirationTime = e.set;
                }

                clearValidatedTimeout(self);

                validatedArrived = true;
                retryingWithSsl = false;
                isConnecting = false;
                isConnected = true;
                reconnectStartedAt = null;

                if (sessionId) {
                    if (!readCookie(sessionCookieName + self.appKey + '-s')) {
                        createSessionCookie(sessionCookieName + self.appKey + '-s', sessionId);
                    }

                    if (!readCookie(sessionCookieName + self.appKey)) {
                        createExpireCookie(sessionCookieName + self.appKey, sessionId, sessionExpirationTime);
                    }
                }

                if (alreadyConnectedFirstTime) {
                    var channelsToRemove = {};

                    // Subscribe to the previously subscribed channels
                    for (var key in subscribedChannels) {
                        // Subscribe again
                        if (subscribedChannels[key].subscribeOnReconnected == true && (subscribedChannels[key].isSubscribing || subscribedChannels[key].isSubscribed)) {
                            subscribedChannels[key].isSubscribing = true;
                            subscribedChannels[key].isSubscribed = false;

                            var domainChannelCharacterIndex = key.indexOf(':');
                            var channelToValidate = key;
                            var hashPerm = null;

                            if (domainChannelCharacterIndex > 0) {
                                channelToValidate = key.substring(0, domainChannelCharacterIndex + 1) + '*';
                            }

                            if (userPerms && userPerms != null) {
                                hashPerm = userPerms[channelToValidate] ? userPerms[channelToValidate] : userPerms[key];
                            }

                            if(subscribedChannels[key].withOptions) {
                                var filter = subscribedChannels[key].filter;
                                var subscriberId = subscribedChannels[key].subscriberId;
                                var regId = ""; // don't resubscribe with notifications
                                ortc.sockjs.send('subscribeoptions;' + self.appKey + ';' + self.authToken + ';' + key + ';' + subscriberId + ';' + regId + ';' + self.pushPlatform + ';' + hashPerm  + ';' + filter);
                            } else if(subscribedChannels[key].filter) {
                                self.sockjs.send('subscribefilter;' + self.appKey + ';' + self.authToken + ';' + key + ';' + hashPerm + ';' + subscribedChannels[key].filter);
                            } else {
                                self.sockjs.send('subscribe;' + self.appKey + ';' + self.authToken + ';' + key + ';' + hashPerm);
                            }                            
                        }
                        else {
                            channelsToRemove[key] = key;
                        }
                    }

                    for (var keyToRemove in channelsToRemove) {
                        delete subscribedChannels[keyToRemove];
                    }

                    messagesBuffer = {};

                    delegateReconnectedCallback(self);
                }
                else {
                    alreadyConnectedFirstTime = true;

                    delegateConnectedCallback(self);
                }
            };

            self.sockjs.onortcerror = function (e) {
                lastKeepAlive = new Date().getTime();

                var data = e.data;
                var operation = data.op;
                var channel = data.ch;
                var error = data.ex ? data.ex : data;

                delegateExceptionCallback(self, error);

                switch (operation) {
                    case 'validate':
                        if(error.indexOf("busy") < 0){
                            invalidConnection = true;
                            clearValidatedTimeout(self);
                            retryingWithSsl = false;
                            stopReconnectProcess();
                        }else{
                            clearValidatedTimeout(self);
                            retryingWithSsl = false;
                        }
                        break;
                    case 'subscribe':
                        if (channel && subscribedChannels[channel]) {
                            subscribedChannels[channel].isSubscribing = false;
                        }
                        break;
                    case 'subscribe_maxsize':
                    case 'unsubscribe_maxsize':
                    case 'shutdown' :
                        clearValidatedTimeout(self);
                        retryingWithSsl = false;
                        break;
                    case 'send_maxsize':
                        if (channel && subscribedChannels[channel]) {
                            subscribedChannels[channel].isSubscribing = false;
                        }

                        stopReconnectProcess();
                        break;
                    default:
                        break;
                }
            };

            self.sockjs.onortcack = function (e) {
                var msgId = e.msgId;
                var msgPart = e.msgPart;
                var curSequenceId = e.curSeq;
                var err = e.err;
                var pendingMsg = pendingPublishMessages[msgId];

                if(pendingMsg) {
                    // clear pending ack timeout
                    clearTimeout(pendingMsg.timeout);

                    if(err) {
                        delete pendingPublishMessages[msgId];
                        if(pendingMsg.callback) {
                            pendingMsg.callback(err);
                        }
                    } else if(msgPart === pendingMsg.totalNumOfParts) {
                        // all message parts acknowledged
                        delete pendingPublishMessages[msgId];
                        if(pendingMsg.callback) {
                            pendingMsg.callback(null, curSequenceId);
                        }
                    }
                }
            }
        }

        return self.sockjs;
    }
244844
function clientOutputBufferLimit(val) {
  if(Array.isArray(val)) {
    val.forEach(function(limit) {
      var type = limit[0]
        , seconds = limit[3];
      if(!~Constants.CLIENT_CLASS.indexOf(type)) {
        throw new Error('Unrecognized client limit class');
      }
      if(seconds < 0) {
        throw new Error(
          'Negative number of seconds in soft limit is invalid');
      }
    })
  }
}
1003161
private static int initializeTimeout() {
//        Integer tmp = java.security.AccessController.doPrivileged(
//                new GetIntegerAction("com.sun.security.ocsp.timeout"));
        Integer tmp = Integer.getInteger("com.sun.security.ocsp.timeout");
        if (tmp == null || tmp < 0) {
            return DEFAULT_CONNECT_TIMEOUT;
        }
        // Convert to milliseconds, as the system property will be
        // specified in seconds
        return tmp * 1000;
    }
35037
function (clusterTimeout) {
        clearReconnectInterval();

        if (isConnecting) {
            delegateExceptionCallback(ortc, 'Unable to connect...');
            disconnectSocket();
        }

        isConnecting = true;

        delegateReconnectingCallback(ortc);

        reconnectStartedAt = new Date().getTime();

        if (clusterUrl && clusterUrl != null) {
            clusterConnection(clusterTimeout);
        }
        else {
            ortc.sockjs = createSocketConnection(url);
        }

        if (!ortc.reconnectTimeoutlId) {
            // Timeout to reconnect
            ortc.reconnectTimeoutlId = setTimeout(function () {
                if (!isConnected) {
                    reconnectSocket(ortc.getConnectionTimeout());
                }
            }, ortc.getConnectionTimeout());
        }
    }