mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 16:12:39 +10:00
ws/socket.io rooms - WIP
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
MessageBody,
|
||||||
OnGatewayConnection,
|
OnGatewayConnection,
|
||||||
SubscribeMessage,
|
SubscribeMessage,
|
||||||
WebSocketGateway,
|
WebSocketGateway,
|
||||||
@ -36,6 +37,21 @@ export class WsGateway implements OnGatewayConnection, OnModuleDestroy {
|
|||||||
client.broadcast.emit('message', data);
|
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() {
|
onModuleDestroy() {
|
||||||
if (this.server) {
|
if (this.server) {
|
||||||
this.server.close();
|
this.server.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user