Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

a client’s channel (see the top of this file)

Implementations§

Source§

impl Client

Source

pub fn connect(ep: Endpoint, cfg: ClientConfig) -> Result<Client, Error>

connect: the handshake starts at once (UDP) or once the WebSocket is open; poll() reports Connected or Disconnected(reason)

Source

pub fn poll(&mut self) -> Option<ClientEvent>

the next event; call it until None every frame (it reads, sends keep-alives, notices timeouts)

Source

pub fn send(&mut self, payload: &[u8]) -> Result<u16, Error>

send a message -> its sequence number (Delivered / Lost name it later; Backlog: the WebSocket has WsOptions::max_unsent bytes waiting, nothing was sent)

Source

pub fn send_reliable(&mut self, payload: &[u8]) -> Result<(), Error>

send a message on the reliable channel: any size up to ClientConfig::max_message, in order, over UDP sent again until the server has it (endpoint::ClientCore::send_reliable). It goes out at reliable_bytes_per_s, the rest with the next polls

Source

pub fn state(&self) -> State

where it stands

Source

pub fn reliable(&self) -> bool

whether the transport is reliable and ordered (a WebSocket)

Source

pub fn max_payload(&self) -> usize

the largest payload the server takes (0 before Connected)

Source

pub fn stats(&self) -> Stats

the connection’s counts

Source

pub fn rtt_ms(&self) -> f32

the smoothed round-trip time in ms (0 before the first ack)

Source

pub fn disconnect(&mut self)

end the connection (DISCONNECT goes out; Disconnected(Local) follows)

Trait Implementations§

Source§

impl Drop for Client

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Freeze for Client
where *const u8 is !null: Freeze, PhantomData<u16>: Freeze, PhantomData<u64>: Freeze, PhantomData<u8>: Freeze, PhantomData<bool>: Freeze, PhantomData<Event>: Freeze, PhantomData<Chunk>: Freeze, *const LeafNode<u16, Vec<u16>> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(u16, Vec<u16>)>>: Freeze, *const LeafNode<u16, (bool, Vec<u8>)> is !null: Freeze, PhantomData<Box<(u16, (bool, Vec<u8>))>>: Freeze, PhantomData<Vec<u8>>: Freeze, PhantomData<ClientEvent>: Freeze, *const ArcInner<UdpSocket> is !null: Freeze, PhantomData<ArcInner<UdpSocket>>: Freeze, *const ArcInner<Mutex<VecDeque<Vec<u8>>>> is !null: Freeze, PhantomData<ArcInner<Mutex<VecDeque<Vec<u8>>>>>: Freeze, *const ArcInner<Atomic<bool>> is !null: Freeze, PhantomData<ArcInner<Atomic<bool>>>: Freeze, *const ArcInner<Shared> is !null: Freeze, PhantomData<ArcInner<Shared>>: Freeze,

§

impl Move for Client

§

impl Send for Client
where RawVecInner: Send, NodeRef<Owned, u16, Vec<u16>, LeafOrInternal>: Send, BoxRaw<(u16, Vec<u16>)>: Send, NodeRef<Owned, u16, (bool, Vec<u8>), LeafOrInternal>: Send, BoxRaw<(u16, (bool, Vec<u8>))>: Send, Arc<UdpSocket>: Send, Arc<Mutex<VecDeque<Vec<u8>>>>: Send, Arc<Atomic<bool>>: Send, Arc<Shared>: Send,

§

impl Sync for Client
where RawVecInner: Sync, NodeRef<Owned, u16, Vec<u16>, LeafOrInternal>: Sync, BoxRaw<(u16, Vec<u16>)>: Sync, NodeRef<Owned, u16, (bool, Vec<u8>), LeafOrInternal>: Sync, BoxRaw<(u16, (bool, Vec<u8>))>: Sync, Arc<UdpSocket>: Sync, Arc<Mutex<VecDeque<Vec<u8>>>>: Sync, Arc<Atomic<bool>>: Sync, Arc<Shared>: Sync,

§

impl Unpin for Client
where *const u8 is !null: Unpin, *const LeafNode<u16, Vec<u16>> is !null: Unpin, Box<(u16, Vec<u16>)>: Unpin, *const LeafNode<u16, (bool, Vec<u8>)> is !null: Unpin, Box<(u16, (bool, Vec<u8>))>: Unpin, Arc<UdpSocket>: Unpin, Arc<Mutex<VecDeque<Vec<u8>>>>: Unpin, Arc<Atomic<bool>>: Unpin, Arc<Shared>: Unpin,

§

impl UnsafeUnpin for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.