From a88ad3cf4d48db66d7fcf8a4c9a3d0557cbab525 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 7 Jan 2021 12:13:12 +0100 Subject: [PATCH] Dont delete PeerSharingConnection because it will be resuse When user try to screen charing with same user, the event send is not a offer but renegociation. So could clear arry only when user out of circle. --- front/src/WebRtc/SimplePeer.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/front/src/WebRtc/SimplePeer.ts b/front/src/WebRtc/SimplePeer.ts index 2d8e5162..08ae99fe 100644 --- a/front/src/WebRtc/SimplePeer.ts +++ b/front/src/WebRtc/SimplePeer.ts @@ -245,9 +245,11 @@ 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. peer.destroy(); - if(!this.PeerScreenSharingConnectionArray.delete(userId)){ + + //Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion + /*if(!this.PeerScreenSharingConnectionArray.delete(userId)){ throw 'Couln\'t delete peer screen sharing connexion'; - } + }*/ //console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size); } catch (err) { console.error("closeConnection", err) @@ -301,11 +303,13 @@ export class SimplePeer { peer.signal(data.signal); } else { console.error('Could not find peer whose ID is "'+data.userId+'" in receiveWebrtcScreenSharingSignal'); + console.info('tentative to create new peer connexion'); + this.sendLocalScreenSharingStreamToUser(data.userId); } } catch (e) { console.error(`receiveWebrtcSignal => ${data.userId}`, e); - //force delete and recreate peer connexion - this.PeerScreenSharingConnectionArray.delete(data.userId); + //Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion + //this.PeerScreenSharingConnectionArray.delete(data.userId); this.receiveWebrtcScreenSharingSignal(data); } } @@ -416,8 +420,8 @@ export class SimplePeer { if (!PeerConnectionScreenSharing.isReceivingScreenSharingStream()) { PeerConnectionScreenSharing.destroy(); - - this.PeerScreenSharingConnectionArray.delete(userId); + //Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion + //this.PeerScreenSharingConnectionArray.delete(userId); } } }