pub struct MessageManager { /* private fields */ }Expand description
Handles incoming/outgoing messages, tracks the delivery status of Messages so that guaranteed Messages can be re-transmitted to the remote host
Implementations§
Source§impl MessageManager
impl MessageManager
Sourcepub fn new(host_type: HostType, channel_kinds: &ChannelKinds) -> Self
pub fn new(host_type: HostType, channel_kinds: &ChannelKinds) -> Self
Creates a new MessageManager
Sourcepub fn send_message(
&mut self,
message_kinds: &MessageKinds,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
channel_kind: &ChannelKind,
message: MessageContainer,
) -> bool
pub fn send_message( &mut self, message_kinds: &MessageKinds, converter: &mut dyn LocalEntityAndGlobalEntityConverterMut, channel_kind: &ChannelKind, message: MessageContainer, ) -> bool
Queues a Message to be transmitted to the remote host. Returns true
if the message was accepted, false if the channel queue was full and
the message was dropped (reliable channels only — unreliable channels
always return true, evicting the oldest queued message if needed).
Sourcepub fn send_request(
&mut self,
message_kinds: &MessageKinds,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
channel_kind: &ChannelKind,
global_request_id: GlobalRequestId,
request: MessageContainer,
)
pub fn send_request( &mut self, message_kinds: &MessageKinds, converter: &mut dyn LocalEntityAndGlobalEntityConverterMut, channel_kind: &ChannelKind, global_request_id: GlobalRequestId, request: MessageContainer, )
Queues a request with global_request_id into the given channel’s send buffer.
Sourcepub fn send_response(
&mut self,
message_kinds: &MessageKinds,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
channel_kind: &ChannelKind,
local_response_id: LocalResponseId,
response: MessageContainer,
)
pub fn send_response( &mut self, message_kinds: &MessageKinds, converter: &mut dyn LocalEntityAndGlobalEntityConverterMut, channel_kind: &ChannelKind, local_response_id: LocalResponseId, response: MessageContainer, )
Queues a response keyed by local_response_id into the given channel’s send buffer.
Sourcepub fn collect_outgoing_messages(&mut self, now: &Instant, rtt_millis: &f32)
pub fn collect_outgoing_messages(&mut self, now: &Instant, rtt_millis: &f32)
Advances all channel senders, re-queuing any messages due for retransmission given current RTT.
Sourcepub fn has_outgoing_messages(&self) -> bool
pub fn has_outgoing_messages(&self) -> bool
Returns whether the Manager has queued Messages that can be transmitted to the remote host
Sourcepub fn write_messages(
&mut self,
channel_kinds: &ChannelKinds,
message_kinds: &MessageKinds,
converter: &mut dyn LocalEntityAndGlobalEntityConverterMut,
writer: &mut BitWriter,
packet_index: PacketIndex,
has_written: &mut bool,
)
pub fn write_messages( &mut self, channel_kinds: &ChannelKinds, message_kinds: &MessageKinds, converter: &mut dyn LocalEntityAndGlobalEntityConverterMut, writer: &mut BitWriter, packet_index: PacketIndex, has_written: &mut bool, )
Encodes all pending outgoing messages across all channels into writer, ordered by channel criticality.
Sourcepub fn read_messages(
&mut self,
channel_kinds: &ChannelKinds,
message_kinds: &MessageKinds,
local_world_manager: &mut LocalWorldManager,
reader: &mut BitReader<'_>,
) -> Result<(), SerdeErr>
pub fn read_messages( &mut self, channel_kinds: &ChannelKinds, message_kinds: &MessageKinds, local_world_manager: &mut LocalWorldManager, reader: &mut BitReader<'_>, ) -> Result<(), SerdeErr>
Parses an incoming message packet, routing each message to its channel’s receiver buffer.
Sourcepub fn receive_messages(
&mut self,
message_kinds: &MessageKinds,
now: &Instant,
entity_converter: &dyn LocalEntityAndGlobalEntityConverter,
entity_waitlist: &mut RemoteEntityWaitlist,
) -> Vec<(ChannelKind, Vec<MessageContainer>)>
pub fn receive_messages( &mut self, message_kinds: &MessageKinds, now: &Instant, entity_converter: &dyn LocalEntityAndGlobalEntityConverter, entity_waitlist: &mut RemoteEntityWaitlist, ) -> Vec<(ChannelKind, Vec<MessageContainer>)>
Retrieve all messages from the channel buffers
Sourcepub fn receive_requests_and_responses(
&mut self,
) -> (Vec<(ChannelKind, Vec<(LocalResponseId, MessageContainer)>)>, Vec<(GlobalRequestId, MessageContainer)>)
pub fn receive_requests_and_responses( &mut self, ) -> (Vec<(ChannelKind, Vec<(LocalResponseId, MessageContainer)>)>, Vec<(GlobalRequestId, MessageContainer)>)
Retrieve all requests from the channel buffers
Trait Implementations§
Source§impl PacketNotifiable for MessageManager
impl PacketNotifiable for MessageManager
Source§fn notify_packet_delivered(&mut self, packet_index: PacketIndex)
fn notify_packet_delivered(&mut self, packet_index: PacketIndex)
Occurs when a packet has been notified as delivered. Stops tracking the status of Messages in that packet.