WebRTC: Difference between revisions

 
(4 intermediate revisions by the same user not shown)
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>


* Note that both clients can continue to update descriptions as the network updates.
*: As long as the signalling is setup correctly, you don't need to worry about what RTCPeerConnection is doing under the hood.


{{ hidden | RTCPeerConnection Example |
{{ hidden | RTCPeerConnection Example |
Line 141: Line 159:
==JavaScript API==
==JavaScript API==


===Multiple Clients===
To handle multiple clients, you simply have one RTCPeerConnection per client.


==Native APIs (C++)==
==Native APIs (C++)==
Line 146: Line 166:
==Resources==
==Resources==
* [https://www.html5rocks.com/en/tutorials/webrtc/basics/ HTML5Rocks: Getting Started with WebRTC (JS)]
* [https://www.html5rocks.com/en/tutorials/webrtc/basics/ HTML5Rocks: Getting Started with WebRTC (JS)]
* [https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample MDN Simple RTCDataChannel sample]
* [https://news.ycombinator.com/item?id=25933016 HackerNews: WebRTC is now a W3C and IETF standard]


==References==
==References==