[][src]Struct naia_shared::Connection

pub struct Connection<T: EventType> { /* fields omitted */ }

Represents a connection to a remote host, and provides functionality to manage the connection and the communications to it

Implementations

impl<T: EventType> Connection<T>[src]

pub fn new(
    address: SocketAddr,
    heartbeat_manager: Timer,
    timeout_manager: Timer,
    ack_manager: AckManager,
    rtt_tracker: RttTracker,
    event_manager: EventManager<T>
) -> Self
[src]

Create a new Connection, given the appropriate underlying managers

pub fn mark_sent(&mut self)[src]

Record that a message has been sent (to prevent needing to send a heartbeat)

pub fn should_send_heartbeat(&self) -> bool[src]

Returns whether a heartbeat message should be sent

pub fn mark_heard(&mut self)[src]

Record that a message has been received from a remote host (to prevent disconnecting from the remote host)

pub fn should_drop(&self) -> bool[src]

Returns whether this connection should be dropped as a result of a timeout

pub fn process_incoming_header(
    &mut self,
    payload: &[u8],
    entity_notifiable: &mut Option<&mut dyn EntityNotifiable>
) -> Box<[u8]>
[src]

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

pub fn process_outgoing_header(
    &mut self,
    packet_type: PacketType,
    payload: &[u8]
) -> Box<[u8]>
[src]

Given a packet payload, start tracking the packet via it's index, attach the appropriate header, and return the packet's resulting underlying bytes

pub fn get_next_packet_index(&self) -> SequenceNumber[src]

Get the next outgoing packet's index

pub fn queue_event(&mut self, event: &impl Event<T>)[src]

Queue up an event to be sent to the remote host

pub fn has_outgoing_events(&self) -> bool[src]

Returns whether there are events to be sent to the remote host

pub fn pop_outgoing_event(
    &mut self,
    next_packet_index: u16
) -> Option<Rc<Box<dyn Event<T>>>>
[src]

Pop the next outgoing event from the queue

pub fn unpop_outgoing_event(
    &mut self,
    next_packet_index: u16,
    event: &Rc<Box<dyn Event<T>>>
)
[src]

If for some reason the next outgoing event could not be written into a message and sent, place it back into the front of the queue

pub fn process_event_data<U: EntityType>(
    &mut self,
    reader: &mut PacketReader,
    manifest: &Manifest<T, U>
)
[src]

Given an incoming packet which has been identified as an event, send the data to the EventManager for processing

pub fn get_incoming_event(&mut self) -> Option<T>[src]

Get the most recent event that has been received from a remote host

pub fn get_address(&self) -> SocketAddr[src]

Get the address of the remote host

pub fn get_rtt(&self) -> f32[src]

Get the Round Trip Time to the remote host

Trait Implementations

impl<T: Debug + EventType> Debug for Connection<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Connection<T>

impl<T> !Send for Connection<T>

impl<T> !Sync for Connection<T>

impl<T> Unpin for Connection<T> where
    T: Unpin

impl<T> !UnwindSafe for Connection<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.