From b147f42f0ad2f429be9b86844e61f757aef21bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 8 Mar 2016 23:07:45 +0200 Subject: [PATCH] show unique user count in acp --- src/socket.io/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/socket.io/index.js b/src/socket.io/index.js index d6744f7d9b..1ce84f076d 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -225,6 +225,7 @@ Sockets.getUserSocketCount = function(uid) { if (!io) { return 0; } + var room = io.sockets.adapter.rooms['uid_' + uid]; return room ? room.length : 0; }; @@ -233,8 +234,14 @@ Sockets.getOnlineUserCount = function() { if (!io) { return 0; } - var room = io.sockets.adapter.rooms.online_users; - return room ? room.length : 0; + var count = 0; + for (var key in io.sockets.adapter.rooms) { + if (io.sockets.adapter.rooms.hasOwnProperty(key) && key.startsWith('uid_')) { + ++ count; + } + } + + return count; }; Sockets.getOnlineAnonCount = function () {