pub struct RTCDataChannel { /* private fields */ }
Expand description

DataChannel represents a WebRTC DataChannel The DataChannel interface represents a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data

Implementations

transport returns the SCTPTransport instance the DataChannel is sending over.

on_open sets an event handler which is invoked when the underlying data transport has been established (or re-established).

on_close sets an event handler which is invoked when the underlying data transport has been closed.

on_message sets an event handler which is invoked on a binary message arrival over the sctp transport from a remote peer. OnMessage can currently receive messages up to 16384 bytes in size. Check out the detach API if you want to use larger message sizes. Note that browser support for larger messages is also limited.

on_error sets an event handler which is invoked when the underlying data transport cannot be read.

send sends the binary message to the DataChannel peer

send_text sends the text message to the DataChannel peer

detach allows you to detach the underlying datachannel. This provides an idiomatic API to work with, however it disables the OnMessage callback. Before calling Detach you have to enable this behavior by calling webrtc.DetachDataChannels(). Combining detached and normal data channels is not supported. Please refer to the data-channels-detach example and the pion/datachannel documentation for the correct way to handle the resulting DataChannel object.

Close Closes the DataChannel. It may be called regardless of whether the DataChannel object was created by this peer or the remote peer.

label represents a label that can be used to distinguish this DataChannel object from other DataChannel objects. Scripts are allowed to create multiple DataChannel objects with the same label.

Ordered returns true if the DataChannel is ordered, and false if out-of-order delivery is allowed.

max_packet_lifetime represents the length of the time window (msec) during which transmissions and retransmissions may occur in unreliable mode.

max_retransmits represents the maximum number of retransmissions that are attempted in unreliable mode.

protocol represents the name of the sub-protocol used with this DataChannel.

negotiated represents whether this DataChannel was negotiated by the application (true), or not (false).

ID represents the ID for this DataChannel. The value is initially null, which is what will be returned if the ID was not provided at channel creation time, and the DTLS role of the SCTP transport has not yet been negotiated. Otherwise, it will return the ID that was either selected by the script or generated. After the ID is set to a non-null value, it will not change.

ready_state represents the state of the DataChannel object.

buffered_amount represents the number of bytes of application data (UTF-8 text and binary data) that have been queued using send(). Even though the data transmission can occur in parallel, the returned value MUST NOT be decreased before the current task yielded back to the event loop to prevent race conditions. The value does not include framing overhead incurred by the protocol, or buffering done by the operating system or network hardware. The value of buffered_amount slot will only increase with each call to the send() method as long as the ready_state is open; however, buffered_amount does not reset to zero once the channel closes.

buffered_amount_low_threshold represents the threshold at which the bufferedAmount is considered to be low. When the bufferedAmount decreases from above this threshold to equal or below it, the bufferedamountlow event fires. buffered_amount_low_threshold is initially zero on each new DataChannel, but the application may change its value at any time. The threshold is set to 0 by default.

set_buffered_amount_low_threshold is used to update the threshold. See buffered_amount_low_threshold().

on_buffered_amount_low sets an event handler which is invoked when the number of bytes of outgoing data becomes lower than the buffered_amount_low_threshold.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.