Draft
This page is not complete.
Once you've established a WebRTC peer connection using the RTCPeerConnection
interface, you're able to send and receive media data between the two peers on the connection. But there's a lot more you can do with WebRTC. In this guide, we'll examine how to add a data channel to a peer connection, which can then be used to exchange arbitrary data; that is, any kind of data we wish, in any format we choose.
The underlying data transport used by the RTCDataChannel
can be created in one of two ways:
datachannel
event). This is the easy way, and works for a wide variety of use cases, but may not be flexible enough for your needs.Let's look at each of these cases, starting with the first, which is the most common.
more details soon.
<<<discuss negotiation and connections, especially RTCDataChannel.negotiated and what happens when true vs false>>>
...
WebRTC data channels support buffering of outbound data. This is handled automatically. While there's no way to control the size of the buffer, you can learn how much data is currently buffered, and you can choose to be notified by an event when the buffer starts to run low on queued data. This makes it easy to write efficient routines that make sure there's always data ready to send without over-using memory or swamping the channel completely.
<<<write more about using bufferedAmount, bufferedAmountLowThreshold, onbufferedamountlow, and bufferedamountlow here>>>
...
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Using_data_channels