Skip to content

Commit

Permalink
feat: 방 관리자 socketid 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
begong313 committed Dec 3, 2024
1 parent 93bddf6 commit dc01111
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/media/src/mediasoup/mediasoup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions apps/media/src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion apps/media/src/room/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { Peer } from './peer';

export class Room {
id: string;
masterSocketId: string;
router: Router;
peers: Map<string, Peer>;

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();
}

Expand Down
4 changes: 2 additions & 2 deletions apps/media/src/signaling/signaling.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down

0 comments on commit dc01111

Please sign in to comment.