Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
fix incorrect merge for pull request #444
Browse files Browse the repository at this point in the history
Conflicts:
	lib/connectors/hybrid/switcher.js

I don't know why pr #444 is lost, but so it is.

Change-Id: I7a154662a1e0a916f05a800f6a5d10eddc815b92
  • Loading branch information
cynron committed Mar 22, 2015
2 parents b20cb4b + e3ab2db commit b2c499e
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions lib/connectors/hybrid/switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ var Switcher = function(server, opts) {
this.wsprocessor = new WSProcessor();
this.tcpprocessor = new TCPProcessor(opts.closeMethod);
this.id = 1;
this.timers = {};
this.timeout = opts.timeout || DEFAULT_TIMEOUT;
this.timeout = (timeout || DEFAULT_TIMEOUT) * 1000;
this.setNoDelay = opts.setNoDelay;

if (!opts.ssl) {
Expand All @@ -51,29 +50,14 @@ Switcher.prototype.newSocket = function(socket) {
return;
}
// if set connection timeout
if(!!this.timeout) {
var timer = setTimeout(function() {
logger.warn('connection is timeout without communication, the remote ip is %s && port is %s', socket.remoteAddress, socket.remotePort);
socket.destroy();
}, this.timeout * 1000);

this.timers[this.id] = timer;
socket.id = this.id++;
}
socket.setTimeout(function() {
logger.warn('connection is timeout without communication, the remote ip is %s && port is %s', socket.remoteAddress, socket.remotePort);
socket.destroy();
}, this.timeout)

var self = this;
socket.once('close', function() {
if (!!socket.id) {
clearTimeout(self.timers[socket.id]);
delete self.timers[socket.id];
}
});

socket.once('data', function(data) {
if(!!socket.id) {
clearTimeout(self.timers[socket.id]);
delete self.timers[socket.id];
}
// FIXME: handle incomplete HTTP method
if(isHttp(data)) {
processHttp(self, self.wsprocessor, socket, data);
Expand Down

0 comments on commit b2c499e

Please sign in to comment.