pub struct Client { /* private fields */ }Expand description
a client’s channel (see the top of this file)
Implementations§
Source§impl Client
impl Client
Sourcepub fn connect(ep: Endpoint, cfg: ClientConfig) -> Result<Client, Error>
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)
Sourcepub fn poll(&mut self) -> Option<ClientEvent>
pub fn poll(&mut self) -> Option<ClientEvent>
the next event; call it until None every frame (it reads, sends keep-alives, notices timeouts)
Sourcepub fn send(&mut self, payload: &[u8]) -> Result<u16, Error>
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)
Sourcepub fn send_reliable(&mut self, payload: &[u8]) -> Result<(), Error>
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
Sourcepub fn max_payload(&self) -> usize
pub fn max_payload(&self) -> usize
the largest payload the server takes (0 before Connected)
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
end the connection (DISCONNECT goes out; Disconnected(Local) follows)