From 11624394792adc9e7ae3776e524d35093572c7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 20 Aug 2020 22:23:22 +0200 Subject: [PATCH] Overloading destroy method instead of having a separate method to remove video. --- front/src/WebRtc/ScreenSharingPeer.ts | 8 ++++---- front/src/WebRtc/SimplePeer.ts | 4 ++-- front/src/WebRtc/VideoPeer.ts | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/front/src/WebRtc/ScreenSharingPeer.ts b/front/src/WebRtc/ScreenSharingPeer.ts index 4b03940c..3ce3c409 100644 --- a/front/src/WebRtc/ScreenSharingPeer.ts +++ b/front/src/WebRtc/ScreenSharingPeer.ts @@ -39,7 +39,7 @@ export class ScreenSharingPeer extends Peer { });*/ this.on('close', () => { - this.closeScreenSharingConnection(); + this.destroy(); }); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -79,16 +79,16 @@ export class ScreenSharingPeer extends Peer { } } - public closeScreenSharingConnection() { + public destroy(error?: Error): void { try { mediaManager.removeActiveScreenSharingVideo(this.userId); // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); - this.destroy(); + super.destroy(error); //console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size); } catch (err) { - console.error("closeConnection", err) + console.error("ScreenSharingPeer::destroy", err) } } diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 489f07a7..498a8608 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -189,7 +189,7 @@ export class SimplePeer { console.warn("Tried to close connection for user "+userId+" but could not find user") return; } - peer.closeConnection(); + peer.destroy(); // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); @@ -220,7 +220,7 @@ export class SimplePeer { // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); - peer.closeScreenSharingConnection(); + peer.destroy(); this.PeerScreenSharingConnectionArray.delete(userId) //console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size); } catch (err) { diff --git a/front/src/WebRtc/VideoPeer.ts b/front/src/WebRtc/VideoPeer.ts index bb624250..ec7f2576 100644 --- a/front/src/WebRtc/VideoPeer.ts +++ b/front/src/WebRtc/VideoPeer.ts @@ -39,7 +39,7 @@ export class VideoPeer extends Peer { });*/ this.on('close', () => { - this.closeConnection(); + this.destroy(); }); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -97,15 +97,15 @@ export class VideoPeer extends Peer { /** * This is triggered twice. Once by the server, and once by a remote client disconnecting */ - public closeConnection() { + public destroy(error?: Error): void { try { mediaManager.removeActiveVideo(this.userId); // FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray" // I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel. //console.log('Closing connection with '+userId); - this.destroy(); + super.destroy(error); } catch (err) { - console.error("closeConnection", err) + console.error("VideoPeer::destroy", err) } }