summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWu Cheng-Han2015-09-27 11:43:55 +0800
committerWu Cheng-Han2015-09-27 11:43:55 +0800
commit2c31b8d809a692db0ad784117340c0aa2d6b69a2 (patch)
tree7b98158557b1a022e0a05247ddf502536996b92d /lib
parentab6d6c77f1fb46033d5096aa650c23c589d963c3 (diff)
Fixed realtime cleaner, socket should defined and notename is not a necessary in disconnect
Diffstat (limited to 'lib')
-rw-r--r--lib/realtime.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/realtime.js b/lib/realtime.js
index 3e99a12d..d2c9fe68 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -107,7 +107,7 @@ var updater = setInterval(function () {
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 && (!socket.rooms || socket.rooms.length <= 0)) {
if (config.debug)
logger.info("cleaner found redundant user: " + key);
disconnectSocketQueue.push(socket);
@@ -353,14 +353,11 @@ function disconnect(socket) {
logger.info("SERVER disconnected a client");
logger.info(JSON.stringify(users[socket.id]));
}
- var notename = getNotenameFromSocket(socket);
- if (!notename) {
- isDisconnectBusy = false;
- return;
- }
+
if (users[socket.id]) {
delete users[socket.id];
}
+ var notename = getNotenameFromSocket(socket);
var note = notes[notename];
if (note) {
delete note.users[socket.id];