From b82cba518ddab40b74698d73361df4732cedc136 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 14 Apr 2020 09:48:30 +0200 Subject: [PATCH] Handles remote peer streams interruption --- assets/js/common/ws.js | 4 ++++ assets/js/components/calls/controller.js | 7 +++++++ assets/js/components/calls/window.js | 10 +++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index 52b39b10..d6165e3a 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -237,6 +237,10 @@ class UserWebSocket { SendEvent("callPeerReady", msg.data); break; + case "call_peer_interrupted_streaming": + SendEvent("callPeerInterruptedStreaming", msg.data); + break; + case "call_closed": SendEvent("callClosed", msg.data); break; diff --git a/assets/js/components/calls/controller.js b/assets/js/components/calls/controller.js index e4f873f8..2986f013 100644 --- a/assets/js/components/calls/controller.js +++ b/assets/js/components/calls/controller.js @@ -111,6 +111,13 @@ document.addEventListener("callPeerReady", (e) => { OpenCalls.get(detail.callID).PeerReady(detail.peerID) }) +document.addEventListener("callPeerInterruptedStreaming", (e) => { + const detail = e.detail + + if(OpenCalls.has(detail.callID)) + OpenCalls.get(detail.callID).RemoveMemberConnection(detail.peerID) +}) + document.addEventListener("callClosed", e => { const callID = e.detail; diff --git a/assets/js/components/calls/window.js b/assets/js/components/calls/window.js index d06d3a6c..a89aa56f 100644 --- a/assets/js/components/calls/window.js +++ b/assets/js/components/calls/window.js @@ -850,9 +850,13 @@ class CallWindow extends CustomEvents { this.refreshButtonsState() // Propagate information - await ws("calls/stop_streaming", { - callID: this.callID - }) + try { + await ws("calls/stop_streaming", { + callID: this.callID + }) + } catch(e) { + console.log("Failed to notify of streaming stop", e) + } } /**