Skip to content

Commit

Permalink
Missed an 'onLine.' prefix in the successful for three+ ping case
Browse files Browse the repository at this point in the history
  • Loading branch information
Havvy committed Dec 12, 2014
1 parent 52df3e0 commit b34f527
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion irc-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var Socket = module.exports = function Socket (config, NetSocket) {
socket.emit("timeout");
}, onLine.timeoutInterval);
} else {
clearTimeout(timeout);
clearTimeout(onLine.timeout);
onLine.timeout = setTimeout(function () {
socket.emit("timeout");
}, onLine.timeoutInterval);
Expand Down
23 changes: 23 additions & 0 deletions test/irc-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ describe("IRC Sockets", function () {

clock.tick(1);
});

it('goes through multiple pings without timing out', function (done) {
socket.on('timeout', function () {
assert(false);
});

var pingsLeft = 4;
void function pingLoop () {
if (pingsLeft === 0) {
done();
return;
}

logfn("Ticking 1000 time units");
clock.tick(1000);
genericsocket.emit("data", MockGenericSocket.messages.ping);
pingsLeft -= 1;
logfn("pingsLeft is now " + pingsLeft);

setImmediate(pingLoop)
clock.tick(1);
}();
});
});

describe('Emitted data', function () {
Expand Down

0 comments on commit b34f527

Please sign in to comment.