Expand description
WebRTC data channels over SCTP.
The Data Channel Establishment Protocol (RFC 8832) and the SCTP-based data channel
layer (RFC 8831): the DATA_CHANNEL_OPEN handshake, the reliability and ordering
parameters, and the payload protocol identifiers that distinguish string from binary
messages.
§Structure
data_channel— one channel’s state and its read/write surface over an SCTP stream, including partial-reliability settings (maxPacketLifeTime,maxRetransmits).message— the DCEP messages themselves:DataChannelOpen,DataChannelAck, and the channel-type encoding.
§Example
use bytes::Bytes;
use rtc_datachannel::message::message_channel_open::{ChannelType, DataChannelOpen};
use rtc_datachannel::message::{Message, message_type::MessageType};
use shared::marshal::{Marshal, Unmarshal};
let open = Message::DataChannelOpen(DataChannelOpen {
channel_type: ChannelType::PartialReliableRexmit,
priority: 256,
reliability_parameter: 3, // give up after 3 retransmissions
label: b"chat".to_vec(),
protocol: Vec::new(),
});
assert_eq!(open.message_type(), MessageType::DataChannelOpen);
let encoded = open.marshal()?;
let mut buf = Bytes::from(encoded.to_vec());
assert_eq!(Message::unmarshal(&mut buf)?, open);Most applications do not depend on this crate directly — the
rtc crate layers it over rtc-sctp and exposes
RTCDataChannel.
Modules§
- data_
channel - One data channel’s state and its read/write surface over an SCTP stream. One data channel over an SCTP stream.
- message
- The DCEP messages exchanged to open, acknowledge and close a channel.