Function WebRTCPeerConnection.createDataChannel
Returns a new WebRTCDataChannel
(or null
on failure) with given label
and optionally configured via the options
dictionary. This method can only be called when the connection is in state constant STATE_NEW
.
There are two ways to create a working data channel: either call createDataChannel
on only one of the peer and listen to dataChannelReceived
on the other, or call createDataChannel
on both peers, with the same values, and the negotiated
option set to true
.
Valid options
are:
godot .d .reference .Ref!(godot.webrtcdatachannel.WebRTCDataChannel) createDataChannel
(
const(String) label,
const(Dictionary) options = make()
) nothrow @nogc;
{ "negotiated": true, # When set to true (default off), means the channel is negotiated out of band. "id" must be set too. data_channel_received will not be called. "id": 1, # When "negotiated" is true this value must also be set to the same value on both peer.
# Only one of maxRetransmits and maxPacketLifeTime can be specified, not both. They make the channel unreliable (but also better at real time). "maxRetransmits": 1, # Specify the maximum number of attempt the peer will make to retransmits packets if they are not acknowledged. "maxPacketLifeTime": 100, # Specify the maximum amount of time before giving up retransmitions of unacknowledged packets (in milliseconds). "ordered": true, # When in unreliable mode (i.e. either "maxRetransmits" or "maxPacketLifetime" is set), "ordered" (true by default) specify if packet ordering is to be enforced.
"protocol": "my-custom-protocol", # A custom sub-protocol string for this channel. }
Note: You must keep a reference to channels created this way, or it will be closed.