Skip to content

Node.js based forum software built for the modern web

one more fix

barisusakli707a062661d6
diff --git a/src/socket.io/index.js b/src/socket.io/index.js
index 29b58e6f18..08654eea35 100644
--- a/src/socket.io/index.js
+++ b/src/socket.io/index.js
@@ -253,19 +253,19 @@ Sockets.in = function(room) {
};
Sockets.uidInRoom = function(uid, room) {
- var clients = io.sockets.clients(room);
+ var socketIds = io.sockets.manager.rooms[room];
+ if (!Array(socketIds) || !socketIds.length) {
+ return false;
+ }
uid = parseInt(uid, 10);
- if (typeof uid === 'number' && uid > 0) {
- clients = clients.filter(function(socketObj) {
- return uid === socketObj.uid;
- });
-
- return clients.length ? true : false;
- } else {
- return false;
+ for (var i=0; i<socketIds.length; ++i) {
+ if (socketIdToUid[socketIds[i]] === uid) {
+ return true;
+ }
}
+ return false;
};
Sockets.getConnectedClients = function() {
@@ -377,7 +377,7 @@ Sockets.getUidsInRoom = function(roomName) {
}
for(var i=0; i<socketids.length; ++i) {
- var uid = socketIdToUid[socketids[i]]
+ var uid = socketIdToUid[socketids[i]];
if (uid && uids.indexOf(uid) === -1) {
uids.push(uid);
}
@@ -401,7 +401,7 @@ Sockets.getAnonCountInRoom = function(roomName) {
}
return count;
-}
+};
Sockets.emitTopicPostStats = emitTopicPostStats;
function emitTopicPostStats(callback) {