diff options
author | Wu Cheng-Han | 2015-10-05 14:32:05 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2015-10-05 14:32:05 +0800 |
commit | 53f26a777177510bf9801759fca6197144217b60 (patch) | |
tree | 31efea587a50137f50cdb48a95900de377bb86c8 /lib | |
parent | 9586e2057f9ede5c0514ecf5f44b72b88e3c6129 (diff) |
Fixed cleaner might not clean user not in connected list and handle if the user socket not exist
Diffstat (limited to 'lib')
-rw-r--r-- | lib/realtime.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/realtime.js b/lib/realtime.js index d2c9fe68..5018d151 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -103,13 +103,19 @@ var updater = setInterval(function () { if (err) return logger.error('updater error', err); }); }, 1000); -//clean when user not in any rooms +//clean when user not in any rooms or user not in connected list var cleaner = setInterval(function () { async.each(Object.keys(users), function (key, callback) { var socket = realtime.io.sockets.connected[key]; - if (socket && (!socket.rooms || socket.rooms.length <= 0)) { + if ((!socket && users[key]) || + (socket && (!socket.rooms || socket.rooms.length <= 0))) { if (config.debug) logger.info("cleaner found redundant user: " + key); + if (!socket) { + socket = { + id: key + }; + } disconnectSocketQueue.push(socket); disconnect(socket); } |