WebRTC: Difference between revisions

713 bytes added ,  19 August 2020
Line 38: Line 38:
</syntaxhighlight>
</syntaxhighlight>


Next the local and remote clients exchange descriptions:


<syntaxhighlight lang="javascript">
const localOffer = await localConnection.createOffer();
localConnection.setLocalDescription(localOffer);
signallingChannel.send(localConnection.localDescription)
# On the remote
const localOffer = signalingChannel.receiveAnswer(); // Actually a callback irl
remoteConnection.setRemoteDescription(localOffer);
const answer = await remoteConnection.createAnswer();
remoteConnection.setLocalDescription(answer);
signallingChannel.send(remoteConnection.localDescription)
# On the local
const remoteDescription = signalingChannel.receiveAnswer();
localConnection.setRemoteDescription(remoteDescription);
</syntaxhighlight>