cm¶
-
class
steam.core.cm.
CMClient
(protocol=0)¶ Bases:
eventemitter.EventEmitter
CMClient provides a secure message channel to Steam CM servers Can be used as mixing or on it’s own.
Incoming messages are parsed and emitted as events using their
steam.enums.emsg.EMsg
as event identifier-
EVENT_CONNECTED
= 'connected'¶ Connection establed to CM server
-
EVENT_DISCONNECTED
= 'disconnected'¶ Connection closed
-
EVENT_CHANNEL_SECURED
= 'channel_secured'¶ After successful completion of encryption handshake
-
PROTOCOL_TCP
= 0¶ TCP protocol enum
-
PROTOCOL_UDP
= 1¶ UDP protocol enum
-
verbose_debug
= False¶ print message connects in debug
-
auto_discovery
= True¶ enables automatic CM discovery
-
current_server_addr
= None¶ (ip, port) tuple
-
connected
= False¶ True
if connected to CM
-
channel_secured
= False¶ True
once secure channel handshake is complete
-
channel_key
= None¶ channel encryption key
-
channel_hmac
= None¶ HMAC secret
-
steam_id
= SteamID(id=0, type='Invalid', universe='Invalid', instance=0)¶ SteamID
of the current user
-
session_id
= None¶ session id when logged in
-
cell_id
= 0¶ cell id provided by CM
-
cm_servers
= None¶ a instance of
CMServerList
-
emit
(event, *args)¶ Emit event with some arguments
Parameters: - event (any type) – event identifier
- args – any or no arguments
-
connect
(retry=0, delay=0)¶ Initiate connection to CM. Blocks until connected unless
retry
is specified.Parameters: Returns: successful connection
Return type:
-
disconnect
()¶ Close connection
-
send
(message)¶ Send a message
Parameters: message ( steam.core.msg.Msg
,steam.core.msg.MsgProto
) – a message instance
-
sleep
(seconds)¶ Yeild and sleep N seconds. Allows other greenlets to run
-
idle
()¶ Yeild in the current greenlet and let other greenlets run
-
-
class
steam.core.cm.
CMServerList
¶ Bases:
object
Managing object for CM servers
Comes with built in list of CM server to bootstrap a connection
To get a server address from the list simply iterate over it
servers = CMServerList() for server_addr in servers: pass
The good servers are returned first, then bad ones. After failing to connect call
mark_bad()
with the server addr. When connection succeeds break out of the loop.-
Good
= 1¶
-
Bad
= 2¶
-
last_updated
= 0¶ timestamp of when the list was last updated
-
cell_id
= 0¶ cell id of the server list
-
bad_timestamp
= 300¶ how long bad mark lasts in seconds
-
clear
()¶ Clears the server list
-
bootstrap_from_dns
()¶ Fetches CM server list from WebAPI and replaces the current one
-
bootstrap_from_webapi
(cell_id=0)¶ Fetches CM server list from WebAPI and replaces the current one
Parameters: cellid ( int
) – cell id (0 = global)Returns: booststrap success Return type: bool
-
reset_all
()¶ Reset status for all servers in the list
-
mark_good
(server_addr)¶ Mark server address as good
Parameters: server_addr ( tuple
) – (ip, port) tuple
-