Fix webrtc back
authorgparant <g.parant@thecodingmachine.com>
Fri, 8 May 2020 09:16:49 +0000 (11:16 +0200)
committergparant <g.parant@thecodingmachine.com>
Fri, 8 May 2020 09:16:49 +0000 (11:16 +0200)
 - Add refuse to join if webrtc room have 4 players.

back/src/Controller/IoSocketController.ts

index 64012349b5b3d996a625d1605bf9400b77f8dd4d..d253cc9efec62b71b50bf3da70915ae0442d893c 100644 (file)
@@ -172,6 +172,9 @@ export class IoSocketController {
         Client.broadcast.emit(SockerIoEvent.WEBRTC_DISCONNECT, JSON.stringify({
             userId: Client.userId
         }));
+
+        //disconnect webrtc room
+        Client.leave(Client.webRtcRoomId);
     }
 
     /**
@@ -186,7 +189,7 @@ export class IoSocketController {
         socket.join(roomId);
         socket.webRtcRoomId = roomId;
         //if two persone in room share
-        if (this.Io.sockets.adapter.rooms[roomId].length < 2) {
+        if (this.Io.sockets.adapter.rooms[roomId].length < 2 || this.Io.sockets.adapter.rooms[roomId].length >= 4) {
             return;
         }
         let clients: Array<any> = Object.values(this.Io.sockets.sockets);