function handleOffer(msg) {
createMyPeerConnection();
myPeerConnection
.setRemoteDescription(msg.description)
.then(() => navigator.mediaDevices.getUserMedia(mediaConstraints))
.then((stream) => {
document.getElementById("local_video").srcObject = stream;
return myPeerConnection.addStream(stream);
})
.then(() => myPeerConnection.createAnswer())
.then((answer) => myPeerConnection.setLocalDescription(answer))
.then(() => {
// Send the answer to the remote peer using the signaling server
})
.catch(handleGetUserMediaError);
}RTCPeerConnection: setRemoteDescription() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.