Struct naia_shared::BaseConnection
source · pub struct BaseConnection<E: Copy + Eq + Hash + Send + Sync> {
pub message_manager: MessageManager,
pub host_world_manager: HostWorldManager<E>,
pub remote_world_manager: RemoteWorldManager<E>,
pub remote_world_reader: RemoteWorldReader<E>,
pub local_world_manager: LocalWorldManager<E>,
/* private fields */
}
Expand description
Represents a connection to a remote host, and provides functionality to manage the connection and the communications to it
Fields§
§message_manager: MessageManager
§host_world_manager: HostWorldManager<E>
§remote_world_manager: RemoteWorldManager<E>
§remote_world_reader: RemoteWorldReader<E>
§local_world_manager: LocalWorldManager<E>
Implementations§
source§impl<E: Copy + Eq + Hash + Send + Sync> BaseConnection<E>
impl<E: Copy + Eq + Hash + Send + Sync> BaseConnection<E>
sourcepub fn new(
address: &Option<SocketAddr>,
host_type: HostType,
user_key: u64,
connection_config: &ConnectionConfig,
channel_kinds: &ChannelKinds,
global_world_manager: &dyn GlobalWorldManagerType<E>
) -> Self
pub fn new( address: &Option<SocketAddr>, host_type: HostType, user_key: u64, connection_config: &ConnectionConfig, channel_kinds: &ChannelKinds, global_world_manager: &dyn GlobalWorldManagerType<E> ) -> Self
Create a new BaseConnection, given the appropriate underlying managers
sourcepub fn mark_sent(&mut self)
pub fn mark_sent(&mut self)
Record that a message has been sent (to prevent needing to send a heartbeat)
sourcepub fn should_send_heartbeat(&self) -> bool
pub fn should_send_heartbeat(&self) -> bool
Returns whether a heartbeat message should be sent
sourcepub fn mark_heard(&mut self)
pub fn mark_heard(&mut self)
Record that a message has been received from a remote host (to prevent disconnecting from the remote host)
sourcepub fn should_drop(&self) -> bool
pub fn should_drop(&self) -> bool
Returns whether this connection should be dropped as a result of a timeout
sourcepub fn process_incoming_header(
&mut self,
header: &StandardHeader,
packet_notifiables: &mut [&mut dyn PacketNotifiable]
)
pub fn process_incoming_header( &mut self, header: &StandardHeader, packet_notifiables: &mut [&mut dyn PacketNotifiable] )
Process an incoming packet, pulling out the packet index number to keep track of the current RTT, and sending the packet to the AckManager to handle packet notification events
sourcepub fn write_header(&mut self, packet_type: PacketType, writer: &mut BitWriter)
pub fn write_header(&mut self, packet_type: PacketType, writer: &mut BitWriter)
Given a packet payload, start tracking the packet via it’s index, attach the appropriate header, and return the packet’s resulting underlying bytes
sourcepub fn next_packet_index(&self) -> PacketIndex
pub fn next_packet_index(&self) -> PacketIndex
Get the next outgoing packet’s index