Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes step06 according to latest specs: sdpParams in RTCIceCandidate constructor and use promises #121

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions step-06/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));

}
}

Expand Down Expand Up @@ -218,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);
Expand All @@ -230,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) {
Expand Down