From e8f1b2d048c64fc11a855d68a9fbf1135fc0a343 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 12:58:45 +0100 Subject: [PATCH] Add clear array peer connection sharing --- front/src/WebRtc/SimplePeer.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 08ae99fe..90d260ee 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -229,6 +229,14 @@ export class SimplePeer { } catch (err) { console.error("closeConnection", err) } + + //if user left discussion, clear array peer connection of sharing + if(this.Users.length === 0) { + for (const userId of this.PeerScreenSharingConnectionArray.keys()) { + this.closeScreenSharingConnection(userId); + this.PeerScreenSharingConnectionArray.delete(userId); + } + } } /**