Renet uses unidirectional channels for communication. Channels are configured via ConnectionConfig.client_channels_config (for client-to-server) and ConnectionConfig.server_channels_config (for server-to-client).
Each channel is defined by a ChannelConfig which includes a unique channel_id, max_memory_usage_bytes, and a send_type that determines the delivery guarantee:
SendType::ReliableOrdered: Guarantees both message delivery and the order of arrival. Requires a resend_time (Duration) to specify how long to wait before resending a lost message.SendType::ReliableUnordered: Guarantees message delivery but does not guarantee the order of arrival. Also requires a resend_time.SendType::Unreliable: No guarantee of delivery or order.
// No guarantee of message delivery or order
let send_type = SendType::Unreliable;
// guarantee of message delivery and order
let send_type = SendType::ReliableOrdered {
// If a message is lost, it will be resent after this duration
resend_time: Duration::from_millis(300)
};
// Guarantee of message delivery but not order
let send_type = SendType::ReliableUnordered {
resend_time: Duration::from_millis(300)
};
let channel_config = ChannelConfig {
// The id for the channel, must be unique within its own list,
// but it can be repeated between the server and client lists.
channel_id: 0,
// Maximum number of bytes that the channel may hold without acknowledgement of messages before becoming full.
max_memory_usage_bytes: 5 * 1024 * 1024, // 5 megabytes
send_type
};