pub struct Channel<'a> { /* private fields */ }Expand description
Channel for sending data to the remote peer.
Get this handle from Rtc::channel().
Implementations§
Source§impl<'a> Channel<'a>
impl<'a> Channel<'a>
Sourcepub fn write(&mut self, binary: bool, buf: &[u8]) -> Result<usize, RtcError>
pub fn write(&mut self, binary: bool, buf: &[u8]) -> Result<usize, RtcError>
Write data to the remote peer and indicate whether it’s text or binary.
Sourcepub fn buffered_amount(&mut self) -> usize
pub fn buffered_amount(&mut self) -> usize
Get the amount of buffered data.
Returns 0 if the channel is closed or encountered some error. This is to be similar to the RTCPeerConnection equivalent
Sourcepub fn set_buffered_amount_low_threshold(&mut self, threshold: usize)
pub fn set_buffered_amount_low_threshold(&mut self, threshold: usize)
Set the threshold to emit an
Event::ChannelBufferedAmountLow
Setting this on a closed or broken channel does not show an error. This is be similar to the RTCPeerConnection equivalent
Sourcepub fn config(&self) -> Option<&ChannelConfig>
pub fn config(&self) -> Option<&ChannelConfig>
Get the channel config.
The config is not available in every case depending on whether the channel was negotiated in- or out of band.
§In-band negotiation (the usual case)
For (regular) in-band negotiation (DCEP, Data Channel Establishment Protocol), this
returns None until the DCEP handshake completes. The config is guaranteed to be
available when Event::ChannelOpen is emitted.
§Out-of-band negotiation
Returns None when the remote side created the data channel connection without using
DCEP. This is called out-of-band negotiation, where the remote peer opens a stream
but doesn’t send the channel configuration through the DCEP protocol messages.
For locally created out-of-band channels, the config is always available since it was provided during channel creation.
In str0m, DCEP is disabled by setting the negotiated field to Some(stream_id) in
ChannelConfig. This corresponds to the negotiated: true property in the
browser’s createDataChannel() dictionary.