Reputation:
What is the best way to get all connected sockets in a selected room. I've found this line :
io.in(roomID).fetchSockets()
But in my nestJS structure I don't have an IO instance.
Upvotes: 0
Views: 1283
Reputation: 127
You can use decorator provided by NestJS. Nest will automatically assign the server instance to this property once it is ready to use.
@WebSocketServer()
server: Server;
Somewhere before constructor and other methods together with other service/class properties. Then you could use it like this: this.server.in(roomID).fetchSockets();
Upvotes: 1