rtc.DataChannel Class
A wrapper for RTCDataChannel. Used to transfer custom data between peers.
Constructor
rtc.DataChannel
(
-
channel
-
[max_buffer]
Parameters:
-
channel
RTCDataChannelThe wrapped native data channel
-
[max_buffer]
Number optionalThe size of the send buffer after which we will delay sending
Methods
_actualSend
()
private
Method which actually sends the data. Implements buffering
connect
()
Promise
Connect to the DataChannel. You will receive messages and will be able to send after calling this.
Returns:
Promise:
Promise which resolves as soon as the DataChannel is open
label
()
String
The label of the DataChannel used to distinguish multiple channels
Returns:
String:
The label
send
(
Promise
-
data
Send data to the peer through the DataChannel
Parameters:
-
data
ObjectThe data to be transferred
Returns:
Promise:
Promise which will be resolved when the data was passed to the native data channel
Events
closed
()
The channel was closed
message
(
-
data
A new messages was received. Triggers only after connect()
was called
Parameters:
-
data
ArrayBufferThe data received