diff options
author | John McLear <john@mclear.co.uk> | 2014-11-23 22:34:30 +0000 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2014-11-23 22:34:30 +0000 |
commit | 945d6c83c1e135dbe305572bae3defe3e1d87000 (patch) | |
tree | 65e3d5d124d7d262ddf0b18723c1928187c7b7ff | |
parent | 555d22245d363b0718a7bfa854957057ebbf80a8 (diff) | |
parent | a3f6b2edb766589e014871b8d656b5e092792c72 (diff) | |
download | etherpad-lite-945d6c83c1e135dbe305572bae3defe3e1d87000.zip |
Merge pull request #2336 from ether/more-socket-io-fixes
more fixes
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 6c029325..598b2df5 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -98,7 +98,14 @@ exports.kickSessionsFromPad = function(padID) return; //skip if there is nobody on this pad - if(socketio.sockets.clients(padID).length == 0) + var roomClients = [], room = socketio.sockets.adapter.rooms[padID]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + + if(roomClients.length == 0) return; //disconnect everyone from this pad @@ -1589,8 +1596,16 @@ function composePadChangesets(padId, startNum, endNum, callback) * Get the number of users in a pad */ exports.padUsersCount = function (padID, callback) { + + var roomClients = [], room = socketio.sockets.adapter.rooms[padID]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + callback(null, { - padUsersCount: socketio.sockets.clients(padID).length + padUsersCount: roomClients.length }); } @@ -1600,7 +1615,14 @@ exports.padUsersCount = function (padID, callback) { exports.padUsers = function (padID, callback) { var result = []; - async.forEach(socketio.sockets.clients(padID), function(roomClient, callback) { + var roomClients = [], room = socketio.sockets.adapter.rooms[padID]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + + async.forEach(roomClients, function(roomClient, callback) { var s = sessioninfos[roomClient.id]; if(s) { authorManager.getAuthor(s.author, function(err, author) { |