Skip to main content

CMClient

Struct CMClient 

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

The base client that handles the connection to a CM server. Use it through SteamClient.

Implementations§

Source§

impl CMClient

Source

pub fn new( configuration: Arc<SteamConfiguration>, identifier: &str, dispatcher: Arc<dyn ClientMsgDispatcher>, ) -> CMClient

Creates a client with the given configuration. The identifier must not be empty (the SteamClient constructors check this).

Source

pub fn configuration(&self) -> &Arc<SteamConfiguration> ⓘ

The configuration for this client.

Source

pub fn id(&self) -> &str

A unique identifier for this client.

Source

pub fn servers(&self) -> &Arc<SmartCMServerList> ⓘ

The list of CM servers.

Source

pub fn local_ip(&self) -> Option<IpAddr>

The local IP of the connection.

Source

pub fn current_end_point(&self) -> Option<SocketAddr>

The endpoint we’re connected to.

Source

pub fn public_ip(&self) -> Option<IpAddr>

Our public IP address, known after a successful logon.

Source

pub fn ip_country_code(&self) -> Option<String>

The country code of our public IP, according to Steam.

Source

pub fn user_country_code(&self) -> Option<String>

The country code of the account.

Source

pub fn universe(&self) -> EUniverse

The universe of this client.

Source

pub fn is_connected(&self) -> bool

Whether we’re connected to a CM server.

Source

pub fn session_token(&self) -> u64

The session token assigned by the server.

Source

pub fn cell_id(&self) -> Option<u32>

The cell id Steam recommends for this client.

Source

pub fn session_id(&self) -> Option<i32>

The session id.

Source

pub fn steam_id(&self) -> Option<SteamID>

The SteamID.

Source

pub fn connection_timeout(&self) -> Duration

The timeout for connecting to a CM server.

Source

pub fn debug_network_listener(&self) -> Option<Arc<dyn IDebugNetworkListener>>

The debug network listener, if any.

Source

pub fn set_debug_network_listener( &self, listener: Option<Arc<dyn IDebugNetworkListener>>, )

Sets the debug network listener.

Source

pub fn expect_disconnection(&self) -> bool

Whether the server is about to close the connection on purpose (e.g. after a log off).

Source

pub fn set_expect_disconnection(&self, expect: bool)

Sets whether the server is about to close the connection on purpose.

Source

pub fn set_connection_factory(&self, factory: ConnectionFactory)

Sets the factory that creates this client’s connections.

Source

pub fn log_debug(&self, category: &str, message: &str)

Writes a line to the debug log under <client id>/<category>, and emits a tracing event too.

Source

pub async fn connect( self: &Arc<Self>, cm_server: Option<ServerRecord>, ) -> Result<(), SteamError>

Connects to a CM server; if cm_server is None, the next one from the server list is used.

A logged-on session that the server closes is moved to another server automatically. Any other disconnect is reported, and it’s up to you to call this again.

Source

pub async fn disconnect(&self)

Disconnects. Counts as user-initiated.

Source

pub async fn disconnect_with(&self, user_initiated: bool)

Disconnects, saying whether it was user-initiated.

Source

pub fn send(&self, msg: &dyn IClientMsg) -> Result<(), SteamError>

Sends a client message, filling in our session id and SteamID.

The message is taken by shared reference, so the session id and SteamID are written into the serialized bytes rather than into msg.

Source

pub async fn on_client_connected(&self)

Called once the client is securely connected.

Source

pub async fn on_client_disconnected(&self, user_initiated: bool)

Called when the connection is gone.

Source

pub fn get_packet_msg(&self, data: Vec<u8>) -> Option<Box<dyn IPacketMsg>>

Parses a raw payload into a packet. Returns None if it can’t be parsed.

Trait Implementations§

Source§

impl Debug for CMClient

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more