NetXClient

Struct NetXClient 

Source
pub struct NetXClient<T> {
    pub server_info: ServerOption,
    pub tls_config: TlsConfig,
    pub mode: u8,
    pub session: T,
    /* private fields */
}
Expand description

Represents a network client with various configurations and states.

Fields§

§server_info: ServerOption

Information about the server.

§tls_config: TlsConfig

Configuration for TLS (Transport Layer Security).

§mode: u8

Mode of the client.

§session: T

Session information.

Implementations§

Source§

impl<T: SessionSave + 'static> NetXClient<T>

Source

pub fn new(server_info: ServerOption, session: T) -> NetxClientArc<T>

Creates a new NetXClient without TLS configuration.

§Parameters
  • server_info - Configuration options for the server.
  • session - The session information.
§Returns
  • NetxClientArc<T> - A new instance of NetXClient wrapped in an Arc.
Source

pub fn init<C: IController + Sync + Send + 'static>(&mut self, controller: C)

Initializes the NetXClient with a given controller.

§Parameters
  • controller - The controller to initialize the client with. It must implement the IController trait and be Sync, Send, and 'static.
Source

pub fn get_mode(&self) -> u8

Gets the current mode of the client.

§Returns
  • u8 - The current mode.
Source

pub fn get_addr_string(&self) -> String

Gets the address of the server as a string.

§Returns
  • String - The server address.
Source

pub fn get_service_info(&self) -> ServerOption

Gets the service information of the server.

§Returns
  • ServerOption - The service information.
Source

pub fn get_session_id(&self) -> i64

Gets the current session ID.

§Returns
  • i64 - The current session ID.
Source

pub fn store_session_id(&mut self, session_id: i64)

Stores the given session ID.

§Parameters
  • session_id - The session ID to store.
Source

pub fn set_network_client(&mut self, client: Arc<NetPeer>)

Sets the network client.

§Parameters
  • client - The network client to set.
Source

pub fn set_connect_stats(&mut self, stats: Option<WReceiver<(bool, String)>>)

Sets the connection status receiver.

§Parameters
  • stats - The connection status receiver to set.
Source

pub fn is_connect(&self) -> bool

Checks if the client is connected.

§Returns
  • bool - true if connected, false otherwise.
Source

pub fn new_serial(&self) -> i64

Generates a new serial number.

§Returns
  • i64 - The new serial number.
Source

pub fn get_callback_len(&mut self) -> usize

Gets the length of the callback dictionary.

§Returns
  • usize - The length of the callback dictionary.

Trait Implementations§

Source§

impl<T> Drop for NetXClient<T>

Custom Drop implementation for NetXClient.

Source§

fn drop(&mut self)

Logs a debug message when the NetXClient is dropped.

Source§

impl<T> Send for NetXClient<T>

Send implementation for NetXClient.

Source§

impl<T> Sync for NetXClient<T>

Sync implementation for NetXClient.

Auto Trait Implementations§

§

impl<T> !Freeze for NetXClient<T>

§

impl<T> !RefUnwindSafe for NetXClient<T>

§

impl<T> Unpin for NetXClient<T>
where T: Unpin,

§

impl<T> !UnwindSafe for NetXClient<T>

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 = 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.