mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-07 14:41:09 +08:00
send stats only if there is at least one client in the room
This commit is contained in:
@@ -248,3 +248,26 @@ exports.checkStatusCode = function (status, accepted_codes) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
exports.getTotalClientInRoom = (io, roomName) => {
|
||||
|
||||
const sockets = io.sockets;
|
||||
|
||||
if (! sockets) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const adapter = sockets.adapter;
|
||||
|
||||
if (! adapter) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const room = adapter.rooms.get(roomName);
|
||||
|
||||
if (room) {
|
||||
return room.size;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user