From d76009cd32f14dade43f043ac1355b22c503e63a Mon Sep 17 00:00:00 2001 From: "Glitch (peerjs-video)" Date: Mon, 7 Sep 2020 20:46:02 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=87=F0=9F=8D=A9=20Checkpoint=20./publi?= =?UTF-8?q?c/main.js:5975361/376=20./views/index.html:5975361/318?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/main.js | 15 ++++++++++++++- views/index.html | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/public/main.js b/public/main.js index bfbd371..f2c4689 100644 --- a/public/main.js +++ b/public/main.js @@ -13,7 +13,7 @@ let logMessage = (message) => { messagesEl.appendChild(newMessage); }; -let renderVideo = (stream, selector = '.remote-video') => { +let renderVideo = (stream, selector = '#remoteVideo') => { document.querySelector(selector).srcObject = stream; }; @@ -32,16 +32,25 @@ peer.on('error', (error) => { // Handle incoming data connection peer.on('connection', (conn) => { logMessage('incoming peer connection!'); + console.log('incoming peer connection!', conn); conn.on('data', (data) => { logMessage(`received: ${data}`); }); conn.on('open', () => { conn.send('hello!'); }); + conn.on('close', () => { + logMessage('Connection closed.'); + }); + conn.on('error', (error) => { + console.error('Error:', error); + logMessage('Error'+error); + }) }); // Handle incoming voice/video connection peer.on('call', (call) => { + console.log('INCOMING CALL', call) navigator.mediaDevices.getUserMedia({video: true, audio: true}) .then((stream) => { call.answer(stream); // Answer the call with an A/V stream. @@ -76,4 +85,8 @@ let connectToPeer = () => { }); }; +let disconnectFromPeer = () => { + +} + window.connectToPeer = connectToPeer; \ No newline at end of file diff --git a/views/index.html b/views/index.html index 58172ca..466cbfe 100644 --- a/views/index.html +++ b/views/index.html @@ -21,12 +21,21 @@ +
+ local +
+
+ remote +
+