1
0
Fork 0
mirror of https://api.glitch.com/git/yaswvc synced 2026-01-12 03:18:10 +00:00

🍬🎓 Checkpoint

./public/main.js:5975361/727
./public/index.html:5975361/22
This commit is contained in:
Glitch (peerjs-video) 2020-09-08 21:11:41 +00:00
parent 1d1ab6096e
commit be3085973a
2 changed files with 17 additions and 3 deletions

View file

@ -89,7 +89,7 @@
<button class="btn btn-sm btn-success" v-on:click="connectToPeer($refs.connectPeer.value);$refs.connectPeer.value = '';">
Connect
</button>
<button class="btn btn-sm btn-danger" v-on:click="disconnectCall()">
<button class="btn btn-sm btn-danger" v-on:click="hangUp()">
Disconnect
</button>
<div class="messages"></div>

View file

@ -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) {