mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Fixed cleaner might not clean user not in connected list and handle if the user socket not exist
This commit is contained in:
parent
9586e2057f
commit
53f26a7771
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue