mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Added cleaner in realtime.js, to clean up users which aren't in any rooms in a interval
This commit is contained in:
parent
950d978fe8
commit
43a175e710
1 changed files with 16 additions and 0 deletions
|
@ -80,6 +80,7 @@ function emitCheck(note) {
|
|||
//actions
|
||||
var users = {};
|
||||
var notes = {};
|
||||
//update when the note is dirty
|
||||
var updater = setInterval(function () {
|
||||
async.each(Object.keys(notes), function (key, callback) {
|
||||
var note = notes[key];
|
||||
|
@ -102,6 +103,21 @@ var updater = setInterval(function () {
|
|||
if (err) return logger.error('updater error', err);
|
||||
});
|
||||
}, 1000);
|
||||
//clean when user not in any rooms
|
||||
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 (config.debug)
|
||||
logger.info("cleaner found redundant user: " + key);
|
||||
disconnectSocketQueue.push(socket);
|
||||
disconnect(socket);
|
||||
}
|
||||
callback();
|
||||
}, function (err) {
|
||||
if (err) return logger.error('cleaner error', err);
|
||||
});
|
||||
}, 60000);
|
||||
|
||||
function getStatus(callback) {
|
||||
db.countFromDB(function (err, data) {
|
||||
|
|
Loading…
Reference in a new issue