From be3085973aa6fc9d33f9ef42370f1b435dcd760d Mon Sep 17 00:00:00 2001 From: "Glitch (peerjs-video)" Date: Tue, 8 Sep 2020 21:11:41 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=AC=F0=9F=8E=93=20Checkpoint=20./publi?= =?UTF-8?q?c/main.js:5975361/727=20./public/index.html:5975361/22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- public/main.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index acedcf9..f807c97 100644 --- a/public/index.html +++ b/public/index.html @@ -89,7 +89,7 @@ -
diff --git a/public/main.js b/public/main.js index 71105b6..7ff07fe 100644 --- a/public/main.js +++ b/public/main.js @@ -32,12 +32,21 @@ var app = new Vue({ let call = this.peer.call(peerId, this.stream); call.on('stream', this.renderVideo); + call.on('close', () => { + console.log(`Call with ${peerId} was closed.`); + this.calls = this.calls.filter(c => c.connectionId === call.connectionId); + }); this.calls.push(call); }, + hangUp: function() { + this.calls.forEach(c => { + this.disconnectCall(c); + }); + }, disconnectCall: function(call) { - // if (!call) return; - console.log('CALLS', this.calls); + if (!call) return; console.log('CALL', call); + call.close(); }, listenForPeerEvents: function () { this.peer.on('open', (id) => { @@ -73,6 +82,11 @@ var app = new Vue({ call.answer(this.stream); // Answer the call with an A/V stream. // this.renderVideo(this.stream, '#localVideo'); call.on('stream', this.renderVideo); + call.on('close', () => { + console.log(`Call with ${call.peer} was closed.`); + this.calls = this.calls.filter(c => c.connectionId === call.connectionId); + }); + this.calls.push(call); }); }, gotDevices: function gotDevices(deviceInfos) {