Struct uflow::server::RemoteClient
source · pub struct RemoteClient { /* private fields */ }
Expand description
Used by a Server
object to represent a connected client.
Implementations§
source§impl RemoteClient
impl RemoteClient
sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true
if the connection is active, that is, a connection handshake has been
completed and the remote host has not yet timed out or disconnected. Returns false
otherwise.
sourcepub fn send(&mut self, data: Box<[u8]>, channel_id: usize, mode: SendMode)
pub fn send(&mut self, data: Box<[u8]>, channel_id: usize, mode: SendMode)
Enqueues a packet for delivery to this client. The packet will be sent on the given channel according to the specified mode.
If the connection is not active, the packet will be silently discarded.
Error Handling
This function will panic if channel_id
does not refer to a valid channel (i.e. if
channel_id >= CHANNEL_COUNT
), or if data.len()
exceeds the maximum packet
size.
sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Gracefully terminates this connection once all packets have been sent.
If any outbound packets are pending, they will be sent prior to disconnecting. Reliable
packets can be assumed to have been delievered, so long as the client does not also
disconnect in the meantime. The connection will remain active until the next call to
Server::step()
with no pending outbound packets.
sourcepub fn disconnect_now(&mut self)
pub fn disconnect_now(&mut self)
Gracefully terminates this connection as soon as possible.
If any outbound packets are pending, they may be flushed prior to disconnecting, but no
packets are guaranteed to be received by the client. The connection will remain active
until the next call to Server::step()
.
sourcepub fn rtt_s(&self) -> Option<f64>
pub fn rtt_s(&self) -> Option<f64>
Returns the current estimate of the round-trip time (RTT), in seconds.
If the RTT has not yet been computed, or if the connection is not active, None
is
returned instead.
sourcepub fn send_buffer_size(&self) -> usize
pub fn send_buffer_size(&self) -> usize
Returns the total size of the send buffer (i.e. those packets which have not yet been acknowledged), in bytes.
This figure represents the amount of memory allocated for outgoing packets. Packets which
are marked TimeSensitive
are included in this total, even if
they would not be sent.