Update in refreshing viewers in playlist

This commit is contained in:
Kasper Rynning-Tønnesen
2018-04-27 13:25:37 +02:00
parent 1c4834211d
commit 3f4662d90e

View File

@@ -59,6 +59,7 @@ function get_short_id(socket) {
function check_inlist(coll, guid, socket, offline)
{
if(coll == undefined) return;
coll = coll.replace(/ /g,'');
if(!offline && coll != undefined){
@@ -79,6 +80,10 @@ function check_inlist(coll, guid, socket, offline)
db.collection("connected_users").update({"_id": "total_users"}, {$addToSet: {total_users: guid + coll}}, function(err, docs){});
});
});
} else {
db.collection("connected_users").find({"_id": coll}, function(err, new_doc) {
io.to(coll).emit("viewers", new_doc[0].users.length);
});
}
});