Enum ClientState

Source
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 to Disconnected. If the client wishes to disconnect from the server, it sends a number of redundant connection disconnect packets (default is 10, can be overridden in ClientConfig) before transitioning to Disconnected.

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

Source§

fn clone(&self) -> ClientState

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Ord for ClientState

Source§

fn cmp(&self, other: &ClientState) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ClientState

Source§

fn eq(&self, other: &ClientState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ClientState

Source§

fn partial_cmp(&self, other: &ClientState) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for ClientState

Source§

impl Eq for ClientState

Source§

impl StructuralPartialEq for ClientState

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.