diff --git a/public/index.html b/public/index.html index 42fe989..acedcf9 100644 --- a/public/index.html +++ b/public/index.html @@ -84,12 +84,12 @@
- +
- -
diff --git a/public/main.js b/public/main.js index daa43fe..71105b6 100644 --- a/public/main.js +++ b/public/main.js @@ -8,6 +8,7 @@ var app = new Vue({ path: '/peerjs/myapp' }), stream: null, + calls: [], }, methods: { logMessage: function(message) { @@ -18,14 +19,6 @@ var app = new Vue({ renderVideo:function(stream, selector = '#remoteVideo') { document.querySelector(selector).srcObject = stream; }, - // createPeer: function() { - // const peer = new Peer(localStorage.getItem('yaswvc-peerId'), { - // host: '/', - // path: '/peerjs/myapp' - // }); - // localStorage.setItem('yaswvc-peerId', peer.id); - // return peer; - // }, connectToPeer: function(peerId) { this.logMessage(`Connecting to ${peerId}...`); @@ -37,8 +30,14 @@ var app = new Vue({ conn.send('hi!'); }); - let call = this.peer.call(this.peerId, this.stream); + let call = this.peer.call(peerId, this.stream); call.on('stream', this.renderVideo); + this.calls.push(call); + }, + disconnectCall: function(call) { + // if (!call) return; + console.log('CALLS', this.calls); + console.log('CALL', call); }, listenForPeerEvents: function () { this.peer.on('open', (id) => { @@ -71,8 +70,8 @@ var app = new Vue({ // Handle incoming voice/video connection this.peer.on('call', (call) => { console.log('INCOMING CALL', call); - call.answer(window.stream); // Answer the call with an A/V stream. - this.renderVideo(window.stream, '#localVideo'); + call.answer(this.stream); // Answer the call with an A/V stream. + // this.renderVideo(this.stream, '#localVideo'); call.on('stream', this.renderVideo); }); },