Skip to content

Commit

Permalink
See #28 Se eliminan las lineas cuando un usuario se va del board y cu…
Browse files Browse the repository at this point in the history
…ando todos los usuarios abandonan un board
  • Loading branch information
glozano committed Aug 11, 2018
1 parent e954e49 commit 9c5c04a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ io.on('connection', function(socket) {
'id': id
}
socket.broadcast.to(room_id).emit("deleteEvent", del);
// db.collection("lines").deleteMany({"user":client_id});
db.collection("lines").deleteMany({"user":client_id});
}
console.log(JSON.stringify(boards));
boards[room_id].connections--;
if(boards[room_id].connections < 1){
// db.collection("lines").deleteMany({"board":room_id});
db.collection("lines").deleteMany({"board":room_id});
}

delete clients[client_id];
Expand All @@ -269,12 +269,10 @@ server.listen(3000, function() {
initDB();
console.log('Mongo running on '+url);

// Borramos boards viejos
// Borramos lineas viejas
db.collection("lines").deleteMany({"timestamp" : {$lt : new Date((new Date())-THREE_HOURS)}});
setInterval(function () {
var THREE_HOURS = 3 * 60 * 60 * 1000; /* ms */
db.collection("lines").deleteMany(
{
"timestamp" : {$lt : new Date((new Date())-THREE_HOURS)}
});
db.collection("lines").deleteMany({"timestamp" : {$lt : new Date((new Date())-THREE_HOURS)}});
}, 1 * 60 * 60 * 1000);
});

0 comments on commit 9c5c04a

Please sign in to comment.