From 3f4662d90ed3377abd763bd06644d0f8587f9ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 27 Apr 2018 13:25:37 +0200 Subject: [PATCH] Update in refreshing viewers in playlist --- server/handlers/functions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/handlers/functions.js b/server/handlers/functions.js index 3c1beda3..f988cfb0 100644 --- a/server/handlers/functions.js +++ b/server/handlers/functions.js @@ -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); + }); } });