Skip to content

Node.js based forum software built for the modern web

show unique user count in acp

Barış Soner Uşaklıb147f42f0ad2
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 () {