From d621aa6360445277be614120a3eb1c49d14c6e0c Mon Sep 17 00:00:00 2001 From: Maria Lopez-Latorre Date: Mon, 2 Nov 2020 20:23:58 +0000 Subject: [PATCH 1/2] Added sdp params in RTCIceCandidate constructor in signaling message callback to fix TypeError thrown as per latest spec --- step-06/js/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/step-06/js/main.js b/step-06/js/main.js index 9ba7701..66ce87f 100644 --- a/step-06/js/main.js +++ b/step-06/js/main.js @@ -186,9 +186,11 @@ function signalingMessageCallback(message) { } else if (message.type === 'candidate') { peerConn.addIceCandidate(new RTCIceCandidate({ - candidate: message.candidate + candidate: message.candidate, + sdpMLineIndex: message.label, + sdpMid: message.id })); - + } } From d030e4f6f0ce613b21469dfc11ec00b1f421eeba Mon Sep 17 00:00:00 2001 From: Maria Lopez-Latorre Date: Mon, 2 Nov 2020 23:25:59 +0000 Subject: [PATCH 2/2] Updated createOffer to use promises instead of callbacks as they were deprecated. Fixes sending first offer null description. --- step-06/js/main.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/step-06/js/main.js b/step-06/js/main.js index 66ce87f..450d093 100644 --- a/step-06/js/main.js +++ b/step-06/js/main.js @@ -220,7 +220,15 @@ if (isInitiator) { onDataChannelCreated(dataChannel); console.log('Creating an offer'); - peerConn.createOffer(onLocalSessionCreated, logError); + peerConn.createOffer().then(function(offer) { + return peerConn.setLocalDescription(offer); + }) + .then(() => { + console.log('sending local desc:', peerConn.localDescription); + sendMessage(peerConn.localDescription); + }) + .catch(logError); + } else { peerConn.ondatachannel = function(event) { console.log('ondatachannel:', event.channel); @@ -232,10 +240,10 @@ if (isInitiator) { function onLocalSessionCreated(desc) { console.log('local session created:', desc); - peerConn.setLocalDescription(desc, function() { + peerConn.setLocalDescription(desc).then(function() { console.log('sending local desc:', peerConn.localDescription); sendMessage(peerConn.localDescription); - }, logError); + }).catch(logError); } function onDataChannelCreated(channel) {