mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 04:32:41 +10:00
ws/socket.io rooms - WIP
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import {
|
||||
MessageBody,
|
||||
OnGatewayConnection,
|
||||
SubscribeMessage,
|
||||
WebSocketGateway,
|
||||
@ -36,6 +37,21 @@ export class WsGateway implements OnGatewayConnection, OnModuleDestroy {
|
||||
client.broadcast.emit('message', data);
|
||||
}
|
||||
|
||||
@SubscribeMessage('messageToRoom')
|
||||
handleSendMessageToRoom(@MessageBody() message: any) {
|
||||
this.server.to(message?.roomId).emit('messageToRoom', message);
|
||||
}
|
||||
|
||||
@SubscribeMessage('join-room')
|
||||
handleJoinRoom(client: Socket, @MessageBody() roomName: string): void {
|
||||
client.join(roomName);
|
||||
}
|
||||
|
||||
@SubscribeMessage('leave-room')
|
||||
handleLeaveRoom(client: Socket, @MessageBody() roomName: string): void {
|
||||
client.leave(roomName);
|
||||
}
|
||||
|
||||
onModuleDestroy() {
|
||||
if (this.server) {
|
||||
this.server.close();
|
||||
|
||||
Reference in New Issue
Block a user