Update examples to only generate SDP when candidates are done gathering

This commit is contained in:
Sean DuBois
2018-08-11 00:23:40 -07:00
parent 02e72796d4
commit d9e6b8b61f
8 changed files with 29 additions and 20 deletions

View File

@@ -11,12 +11,14 @@ sendChannel.onopen = () => console.log('sendChannel has opened')
sendChannel.onmessage = e => log(`sendChannel got '${e.data}'`)
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState)
pc.onicecandidate = event => {
if (event.candidate === null) {
document.getElementById('localSessionDescription').value = btoa(pc.localDescription.sdp)
}
}
pc.onnegotiationneeded = e =>
pc.createOffer({ }).then(d => {
document.getElementById('localSessionDescription').value = btoa(d.sdp)
return pc.setLocalDescription(d)
}).catch(log)
pc.createOffer().then(d => pc.setLocalDescription(d)).catch(log)
window.sendMessage = () => {
let message = document.getElementById('message').value