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
impl CMClient
Sourcepub fn new(
configuration: Arc<SteamConfiguration>,
identifier: &str,
dispatcher: Arc<dyn ClientMsgDispatcher>,
) -> CMClient
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).
Sourcepub fn configuration(&self) -> &Arc<SteamConfiguration> ⓘ
pub fn configuration(&self) -> &Arc<SteamConfiguration> ⓘ
The configuration for this client.
Sourcepub fn servers(&self) -> &Arc<SmartCMServerList> ⓘ
pub fn servers(&self) -> &Arc<SmartCMServerList> ⓘ
The list of CM servers.
Sourcepub fn current_end_point(&self) -> Option<SocketAddr>
pub fn current_end_point(&self) -> Option<SocketAddr>
The endpoint we’re connected to.
Sourcepub fn public_ip(&self) -> Option<IpAddr>
pub fn public_ip(&self) -> Option<IpAddr>
Our public IP address, known after a successful logon.
Sourcepub fn ip_country_code(&self) -> Option<String>
pub fn ip_country_code(&self) -> Option<String>
The country code of our public IP, according to Steam.
Sourcepub fn user_country_code(&self) -> Option<String>
pub fn user_country_code(&self) -> Option<String>
The country code of the account.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether we’re connected to a CM server.
Sourcepub fn session_token(&self) -> u64
pub fn session_token(&self) -> u64
The session token assigned by the server.
Sourcepub fn session_id(&self) -> Option<i32>
pub fn session_id(&self) -> Option<i32>
The session id.
Sourcepub fn connection_timeout(&self) -> Duration
pub fn connection_timeout(&self) -> Duration
The timeout for connecting to a CM server.
Sourcepub fn debug_network_listener(&self) -> Option<Arc<dyn IDebugNetworkListener>>
pub fn debug_network_listener(&self) -> Option<Arc<dyn IDebugNetworkListener>>
The debug network listener, if any.
Sourcepub fn set_debug_network_listener(
&self,
listener: Option<Arc<dyn IDebugNetworkListener>>,
)
pub fn set_debug_network_listener( &self, listener: Option<Arc<dyn IDebugNetworkListener>>, )
Sets the debug network listener.
Sourcepub fn expect_disconnection(&self) -> bool
pub fn expect_disconnection(&self) -> bool
Whether the server is about to close the connection on purpose (e.g. after a log off).
Sourcepub fn set_expect_disconnection(&self, expect: bool)
pub fn set_expect_disconnection(&self, expect: bool)
Sets whether the server is about to close the connection on purpose.
Sourcepub fn set_connection_factory(&self, factory: ConnectionFactory)
pub fn set_connection_factory(&self, factory: ConnectionFactory)
Sets the factory that creates this client’s connections.
Sourcepub fn log_debug(&self, category: &str, message: &str)
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.
Sourcepub async fn connect(
self: &Arc<Self>,
cm_server: Option<ServerRecord>,
) -> Result<(), SteamError>
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.
Sourcepub async fn disconnect(&self)
pub async fn disconnect(&self)
Disconnects. Counts as user-initiated.
Sourcepub async fn disconnect_with(&self, user_initiated: bool)
pub async fn disconnect_with(&self, user_initiated: bool)
Disconnects, saying whether it was user-initiated.
Sourcepub fn send(&self, msg: &dyn IClientMsg) -> Result<(), SteamError>
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.
Sourcepub async fn on_client_connected(&self)
pub async fn on_client_connected(&self)
Called once the client is securely connected.
Sourcepub async fn on_client_disconnected(&self, user_initiated: bool)
pub async fn on_client_disconnected(&self, user_initiated: bool)
Called when the connection is gone.
Sourcepub fn get_packet_msg(&self, data: Vec<u8>) -> Option<Box<dyn IPacketMsg>>
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.