mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 15:16:52 +08:00
Update examples to only generate SDP when candidates are done gathering
This commit is contained in:
@@ -8,7 +8,7 @@ go get github.com/pions/webrtc/examples/data-channels
|
||||
```
|
||||
|
||||
### Open data-channels example page
|
||||
[jsfiddle.net](https://jsfiddle.net/gh/get/library/pure/pions/webrtc/tree/master/examples/data-channels/jsfiddle)
|
||||
[jsfiddle.net](http://jsfiddle.net/9tsx15mg/1/)
|
||||
|
||||
### Run data-channels, with your browsers SessionDescription as stdin
|
||||
In the jsfiddle the top textarea is your browser's session description, copy that and:
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user