Skip to content

Commit

Permalink
socket: clear timer after sending one noop packet (fixes #174)
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed May 31, 2013
1 parent a7697c2 commit 752dab4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/socket.js
Expand Up @@ -2,8 +2,8 @@
* Module dependencies.
*/

var EventEmitter = require('events').EventEmitter
, debug = require('debug')('engine:socket')
var EventEmitter = require('events').EventEmitter;
var debug = require('debug')('engine:socket');

/**
* Module exports.
Expand Down Expand Up @@ -177,14 +177,13 @@ Socket.prototype.maybeUpgrade = function (transport) {
transport.send([{ type: 'pong', data: 'probe' }]);

// we force a polling cycle to ensure a fast upgrade
function check () {
self.checkIntervalTimer = setInterval(function(){
if ('polling' == self.transport.name && self.transport.writable) {
debug('writing a noop packet to polling for fast upgrade');
self.transport.send([{ type: 'noop' }]);
clearInterval(self.checkIntervalTimer);
}
}

self.checkIntervalTimer = setInterval(check, 100);
}, 100);
} else if ('upgrade' == packet.type && self.readyState == 'open') {
debug('got upgrade packet - upgrading');
self.upgraded = true;
Expand Down Expand Up @@ -327,7 +326,7 @@ Socket.prototype.flush = function () {
var wbuf = this.writeBuffer;
this.writeBuffer = [];
if (!this.transport.supportsFraming) {
this.sentCallbackFn.push(this.packetsFn)
this.sentCallbackFn.push(this.packetsFn);
} else {
this.sentCallbackFn.push.apply(this.sentCallbackFn, this.packetsFn);
}
Expand Down

0 comments on commit 752dab4

Please sign in to comment.