From 0653961071f70c4b28d6ce5842df25adfdd12201 Mon Sep 17 00:00:00 2001 From: Corey Cole Date: Thu, 2 Jan 2020 15:43:16 -0800 Subject: [PATCH] fix(signaling): save reference to peer connection before removing it Before, the peer connection would always be null when we null check it. Now we save a reference to it when it is removed so we can properly call `pc.close()` --- lib/src/call_sample/signaling.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/src/call_sample/signaling.dart b/lib/src/call_sample/signaling.dart index 76c9e83..11ef011 100644 --- a/lib/src/call_sample/signaling.dart +++ b/lib/src/call_sample/signaling.dart @@ -201,7 +201,7 @@ class Signaling { case 'leave': { var id = data; - _peerConnections.remove(id); + var pc = _peerConnections.remove(id); _dataChannels.remove(id); if (_localStream != null) { @@ -209,10 +209,8 @@ class Signaling { _localStream = null; } - var pc = _peerConnections[id]; if (pc != null) { pc.close(); - _peerConnections.remove(id); } this._sessionId = null; if (this.onStateChange != null) {