From dc011115b069cb5c294e794094cae9c33401c158 Mon Sep 17 00:00:00 2001 From: JongBin Noh <95959567+begong313@users.noreply.github.com> Date: Tue, 3 Dec 2024 23:03:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B0=A9=20=EA=B4=80=EB=A6=AC=EC=9E=90?= =?UTF-8?q?=20socketid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/media/src/mediasoup/mediasoup.service.ts | 4 ++-- apps/media/src/room/room.service.ts | 4 ++-- apps/media/src/room/room.ts | 4 +++- apps/media/src/signaling/signaling.gateway.ts | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/media/src/mediasoup/mediasoup.service.ts b/apps/media/src/mediasoup/mediasoup.service.ts index 6d2467f6..748b833e 100644 --- a/apps/media/src/mediasoup/mediasoup.service.ts +++ b/apps/media/src/mediasoup/mediasoup.service.ts @@ -48,7 +48,7 @@ export class MediasoupService implements OnModuleInit { return worker; } - async createRoom(roomId: string) { + async createRoom(roomId: string, masterSocketId: string) { const isExistRoom = this.roomService.existRoom(roomId); if (isExistRoom) { return roomId; @@ -59,7 +59,7 @@ export class MediasoupService implements OnModuleInit { mediaCodecs: this.mediasoupConfig.router.mediaCodecs, }); - return this.roomService.createRoom(roomId, router); + return this.roomService.createRoom(roomId, router, masterSocketId); } joinRoom(roomId: string, socketId: string, nickname: string) { diff --git a/apps/media/src/room/room.service.ts b/apps/media/src/room/room.service.ts index 848fc443..53cd5872 100644 --- a/apps/media/src/room/room.service.ts +++ b/apps/media/src/room/room.service.ts @@ -11,8 +11,8 @@ export class RoomService { constructor() {} - createRoom(roomId: string, router: Router) { - const room = new Room(roomId, router); + createRoom(roomId: string, router: Router, masterSocketId: string) { + const room = new Room(roomId, router, masterSocketId); this.rooms.set(roomId, room); return roomId; } diff --git a/apps/media/src/room/room.ts b/apps/media/src/room/room.ts index e2485668..e7f5fb41 100644 --- a/apps/media/src/room/room.ts +++ b/apps/media/src/room/room.ts @@ -6,12 +6,14 @@ import { Peer } from './peer'; export class Room { id: string; + masterSocketId: string; router: Router; peers: Map; - constructor(roomId: string, router: Router) { + constructor(roomId: string, router: Router, masterSocketId: string) { this.id = roomId; this.router = router; + this.masterSocketId = masterSocketId; this.peers = new Map(); } diff --git a/apps/media/src/signaling/signaling.gateway.ts b/apps/media/src/signaling/signaling.gateway.ts index 162d8fe5..c46be289 100644 --- a/apps/media/src/signaling/signaling.gateway.ts +++ b/apps/media/src/signaling/signaling.gateway.ts @@ -24,8 +24,8 @@ export class SignalingGateway implements OnGatewayDisconnect { ) {} @SubscribeMessage(SOCKET_EVENTS.createRoom) - async handleCreateRoom(@MessageBody('roomId') roomId: string) { - await this.mediasoupService.createRoom(roomId); + async handleCreateRoom(@ConnectedSocket() client: Socket, @MessageBody('roomId') roomId: string) { + await this.mediasoupService.createRoom(roomId, client.id); return { roomId }; }