gc¶
GameCoordinator
is used to proxy messages from/to GC.
It takes care of the encapsulation details, but on its own is not
enough to communicate with a given GC.
Example implementation of Dota 2 GC client with inheritance.
import myDotaModule
from steam.client import SteamClient
from steam.core.msg import GCMsgHdrProto
from steam.client.gc import GameCoordinator
class ExampleDotaClient(GameCoordinator):
def __init__(self, steam):
GameCoordinator.__init__(self, steam, 570)
def _process_gc_message(self, emsg, header, body):
if emsg == 4004: # EMsgGCClientWelcome
message = myDotaModule.gcsdk_gcmessages_pb2.CMsgClientWelcome()
message.ParseFromString(body)
print message
def send_hello(self):
header = GCMsgHdrProto(4006) # EMsgGCClientHello
body = myDotaModule.gcsdk_gcmessages_pb2.CMsgClientHello()
self.send(header, body.SerializeToString())
client = SteamClient()
dota = ExampleDotaClient(client)
client.login()
client.games_played([570])
dota.send_hello()
The above code assumes that we have a myDotaModule
that contains the appropriate
protobufs needed to (de)serialize message for communication with GC.
-
class
steam.client.gc.
GameCoordinator
(steam_client, app_id)¶ Bases:
eventemitter.EventEmitter
GameCoordinator
is used to proxy messages from/to GCParameters: - steam_client (
steam.client.SteamClient
) – steam client instance - app_id (
int
) – app id of the application
Incoming messages are emitted as events using their
EMsg
as an event identifier.Parameters: - header (
steam.core.msg.GCMsgHdr
) – message header - body (
bytes
) – raw message body
-
emit
(event, *args)¶ Emit event with some arguments
Parameters: - event (any type) – event identifier
- args – any or no arguments
- steam_client (