From b8ef3406f49f0b0742f5be5da18daa3b47cae087 Mon Sep 17 00:00:00 2001 From: Markleford Date: Tue, 22 Apr 2014 13:57:42 -0400 Subject: [PATCH 1/2] Init .disconnectedSince to null (not undefined) As discussed in issue #77, user.connected() is broken unless we differentiate values of null vs undefined in .disconnectedSince --- src/server/cloak/user.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/cloak/user.js b/src/server/cloak/user.js index d08c118..1a27bfa 100644 --- a/src/server/cloak/user.js +++ b/src/server/cloak/user.js @@ -10,6 +10,7 @@ module.exports = (function() { this.id = uuid.v4(); this._socket = socket; this.name = 'Nameless User'; + this.disconnectedSince = null; } User.prototype = { From f8cf7974531ab92622a10d074372c4f254f33f0f Mon Sep 17 00:00:00 2001 From: Markleford Date: Tue, 22 Apr 2014 14:02:21 -0400 Subject: [PATCH 2/2] Null out user.disconnectedSince, don't delete As discussed in issue #77, differentiating null vs undefined value for .disconnectedSince is important to user.connected() strict equality test --- src/server/cloak/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/cloak/index.js b/src/server/cloak/index.js index ca7502a..966e05d 100644 --- a/src/server/cloak/index.js +++ b/src/server/cloak/index.js @@ -130,7 +130,7 @@ module.exports = (function() { if (user !== undefined) { socketIdToUserId[socket.id] = uid; user._socket = socket; - delete user.disconnectedSince; + user.disconnectedSince = null; cloak._setupHandlers(socket); socket.emit('cloak-resumeResponse', { valid: true,