pub enum ClientState {
ConnectTokenExpired,
ConnectionTimedOut,
ConnectionRequestTimedOut,
ChallengeResponseTimedOut,
ConnectionDenied,
Disconnected,
SendingConnectionRequest,
SendingChallengeResponse,
Connected,
}
Expand description
The states in the client state machine.
The initial state is Disconnected
.
When a client wants to connect to a server, it requests a connect token from the web backend.
To begin this process, it transitions to SendingConnectionRequest
with the first server address in the connect token.
After that the client can either transition to SendingChallengeResponse
or one of the error states.
While in SendingChallengeResponse
, when the client receives a connection keep-alive packet from the server,
it stores the client index and max clients in the packet, and transitions to Connected
.
Any payload packets received prior to Connected
are discarded.
Connected
is the final stage in the connection process and represents a successful connection to the server.
While in this state:
- The client application may send payload packets to the server.
- In the absence of payload packets sent by the client application, the client generates and sends connection keep-alive packets
to the server at some rate (default is 10HZ, can be overridden in
ClientConfig
). - If no payload or keep-alive packets are received from the server within the timeout period specified in the connect token,
the client transitions to
ConnectionTimedOut
. - While
Connected
, if the client receives a disconnect packet from the server, it transitions toDisconnected
. If the client wishes to disconnect from the server, it sends a number of redundant connection disconnect packets (default is 10, can be overridden inClientConfig
) before transitioning toDisconnected
.
Variants§
ConnectTokenExpired
The connect token has expired.
ConnectionTimedOut
The client has timed out while trying to connect to the server, or while connected to the server due to a lack of packets received/sent.
ConnectionRequestTimedOut
The client has timed out while waiting for a response from the server after sending a connection request packet.
ChallengeResponseTimedOut
The client has timed out while waiting for a response from the server after sending a challenge response packet.
ConnectionDenied
The server has denied the client’s connection request, most likely due to the server being full.
Disconnected
The client is disconnected from the server.
SendingConnectionRequest
The client is waiting for a response from the server after sending a connection request packet.
SendingChallengeResponse
The client is waiting for a response from the server after sending a challenge response packet.
Connected
The client is connected to the server.
Trait Implementations§
Source§impl Clone for ClientState
impl Clone for ClientState
Source§fn clone(&self) -> ClientState
fn clone(&self) -> ClientState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more