(padID: string)
| 1684 | }; |
| 1685 | |
| 1686 | const _getRoomSockets = (padID: string) => { |
| 1687 | const ns = socketio.sockets; // Default namespace. |
| 1688 | // We could call adapter.clients(), but that method is unnecessarily asynchronous. Replicate what |
| 1689 | // it does here, but synchronously to avoid a race condition. This code will have to change when |
| 1690 | // we update to socket.io v3. |
| 1691 | const room = ns.adapter.rooms?.get(padID); |
| 1692 | |
| 1693 | if (!room) return []; |
| 1694 | |
| 1695 | return Array.from(room) |
| 1696 | .map(socketId => ns.sockets.get(socketId)) |
| 1697 | .filter(socket => socket); |
| 1698 | }; |
| 1699 | |
| 1700 | /** |
| 1701 | * Get the number of users in a pad |
no test coverage detected