Struct laminar::VirtualConnection [−][src]
pub struct VirtualConnection { pub last_heard: Instant, pub last_sent: Instant, pub remote_address: SocketAddr, // some fields omitted }
Contains the information about a certain ‘virtual connection’ over udp. This connections also keeps track of network quality, processing packets, buffering data related to connection etc.
Fields
last_heard: Instant
Last time we received a packet from this client
last_sent: Instant
Last time we sent a packet to this client
remote_address: SocketAddr
The address of the remote endpoint
Implementations
impl VirtualConnection
[src]
impl VirtualConnection
[src]pub fn new(
addr: SocketAddr,
config: &Config,
time: Instant
) -> VirtualConnection
[src]
pub fn new(
addr: SocketAddr,
config: &Config,
time: Instant
) -> VirtualConnection
[src]Creates and returns a new Connection that wraps the provided socket address
pub fn record_send(&mut self) -> bool
[src]
pub fn record_send(&mut self) -> bool
[src]Records that this connection has sent a packet. Returns whether the connection has become acknowledged because of this send.
pub fn record_recv(&mut self) -> bool
[src]
pub fn record_recv(&mut self) -> bool
[src]Records that this connection has sent a packet. Returns whether the connection has become acknowledged because of this send.
pub fn is_established(&self) -> bool
[src]
pub fn is_established(&self) -> bool
[src]Returns if the connection has been established
pub fn packets_in_flight(&self) -> u16
[src]
pub fn packets_in_flight(&self) -> u16
[src]Returns the current number of not yet acknowledged packets
pub fn last_heard(&self, time: Instant) -> Duration
[src]
pub fn last_heard(&self, time: Instant) -> Duration
[src]Returns a Duration representing the interval since we last heard from the client
pub fn last_sent(&self, time: Instant) -> Duration
[src]
pub fn last_sent(&self, time: Instant) -> Duration
[src]Returns a Duration representing the interval since we last sent to the client
pub fn process_outgoing<'a>(
&mut self,
packet: PacketInfo<'a>,
last_item_identifier: Option<u16>,
time: Instant
) -> Result<OutgoingPackets<'a>>
[src]
pub fn process_outgoing<'a>(
&mut self,
packet: PacketInfo<'a>,
last_item_identifier: Option<u16>,
time: Instant
) -> Result<OutgoingPackets<'a>>
[src]Pre-processes the given buffer to be sent over the network.
pub fn process_incoming(
&mut self,
received_data: &[u8],
time: Instant
) -> Result<IncomingPackets>
[src]
pub fn process_incoming(
&mut self,
received_data: &[u8],
time: Instant
) -> Result<IncomingPackets>
[src]Processes the incoming data and returns a packet once the data is complete.
pub fn gather_dropped_packets(&mut self) -> Vec<SentPacket>
[src]
pub fn gather_dropped_packets(&mut self) -> Vec<SentPacket>
[src]Gathers dropped packets from the acknowledgment handler.
Note that after requesting dropped packets the dropped packets will be removed from this client.
Trait Implementations
impl Connection for VirtualConnection
[src]
impl Connection for VirtualConnection
[src]type ReceiveEvent = SocketEvent
type ReceiveEvent = SocketEvent
Defines a connection event type.
fn create_connection(
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
address: SocketAddr,
time: Instant
) -> VirtualConnection
[src]
fn create_connection(
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
address: SocketAddr,
time: Instant
) -> VirtualConnection
[src]Creates new connection and initialize it by sending an connection event to the user.
- address - defines a address that connection is associated with.
- time - creation time, used by connection, so that it doesn’t get dropped immediately or send heartbeat packet.
- initial_data - if initiated by remote host, this will hold that a packet data.
fn is_established(&self) -> bool
[src]
fn is_established(&self) -> bool
[src]Connections are considered established once they both have had a send and a receive.
fn should_drop(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
time: Instant
) -> bool
[src]
fn should_drop(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
time: Instant
) -> bool
[src]Determines if the given Connection
should be dropped due to its state.
fn process_packet(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
payload: &[u8],
time: Instant
)
[src]
fn process_packet(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
payload: &[u8],
time: Instant
)
[src]Processes a received packet: parse it and emit an event.
fn process_event(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
event: Self::SendEvent,
time: Instant
)
[src]
fn process_event(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
event: Self::SendEvent,
time: Instant
)
[src]Processes a received event and send a packet.
fn update(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
time: Instant
)
[src]
fn update(
&mut self,
messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
time: Instant
)
[src]Processes various connection-related tasks: resend dropped packets, send heartbeat packet, etc… This function gets called very frequently.
Auto Trait Implementations
impl RefUnwindSafe for VirtualConnection
impl Send for VirtualConnection
impl Sync for VirtualConnection
impl Unpin for VirtualConnection
impl UnwindSafe for VirtualConnection
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,