From 103cd2315dc69013fe2b3d871306a386e1f188a3 Mon Sep 17 00:00:00 2001 From: Matteo Scotuzzi Date: Tue, 5 Jan 2016 23:54:51 +0100 Subject: [PATCH 1/2] Updated to Socket.IO v1 api in case of active signalmaster's maxClients configuration --- sockets.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sockets.js b/sockets.js index 41a1c221..002400be 100644 --- a/sockets.js +++ b/sockets.js @@ -142,7 +142,12 @@ module.exports = function (server, config) { } function clientsInRoom(name) { - return io.sockets.clients(name).length; + var room = io.sockets.adapter.rooms[name]; + if (room && room.length) { + return room.length; + } else { + return 0; + } } }; From ccecaea9af1ddd95ca84c1e000b3a39cdffe7452 Mon Sep 17 00:00:00 2001 From: Matteo Scotuzzi Date: Sat, 9 Jan 2016 15:04:31 +0100 Subject: [PATCH 2/2] we want the number of keys in the room object to determine the number of clients --- sockets.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sockets.js b/sockets.js index 002400be..2bb1c13a 100644 --- a/sockets.js +++ b/sockets.js @@ -142,9 +142,10 @@ module.exports = function (server, config) { } function clientsInRoom(name) { - var room = io.sockets.adapter.rooms[name]; - if (room && room.length) { - return room.length; + var adapter = io.nsps['/'].adapter; + var room = adapter.rooms[name]; + if (room && Object.keys(room).length) { + return Object.keys(room).length; } else { return 0; }