mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
PadMessageHandler: Fix fetching of socket.io Sockets for a pad
This commit is contained in:
parent
9cd67cd990
commit
392d9dcfde
1 changed files with 8 additions and 10 deletions
|
@ -1409,16 +1409,14 @@ const composePadChangesets = async (padId, startNum, endNum) => {
|
|||
};
|
||||
|
||||
const _getRoomSockets = (padID) => {
|
||||
const roomSockets = [];
|
||||
const room = socketio.sockets.adapter.rooms[padID];
|
||||
|
||||
if (room) {
|
||||
for (const id of Object.keys(room.sockets)) {
|
||||
roomSockets.push(socketio.sockets.sockets[id]);
|
||||
}
|
||||
}
|
||||
|
||||
return roomSockets;
|
||||
const ns = socketio.sockets; // Default namespace.
|
||||
const adapter = ns.adapter;
|
||||
// We could call adapter.clients(), but that method is unnecessarily asynchronous. Replicate what
|
||||
// it does here, but synchronously to avoid a race condition. This code will have to change when
|
||||
// we update to socket.io v3.
|
||||
const room = adapter.rooms[padID];
|
||||
if (!room) return [];
|
||||
return Object.keys(room.sockets).map((id) => ns.connected[id]).filter((s) => s);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue