Fixed realtime cleaner, socket should defined and notename is not a necessary in disconnect

This commit is contained in:
Wu Cheng-Han 2015-09-27 11:43:55 +08:00
parent ab6d6c77f1
commit 2c31b8d809

View file

@ -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];