diff --git a/steam/client/gc.py b/steam/client/gc.py index 912ed03..f2ca3d8 100644 --- a/steam/client/gc.py +++ b/steam/client/gc.py @@ -1,12 +1,21 @@ """ -Example usage for messages to the Dota 2 GC. +:class:`GameCoordinator` is used to proxy messages from/to GC. +It takes care of the encapsulation details, but on it's own is not +enough to communicate with a given GC. + +Example usage for sending client hello to Dota 2's GC. .. code:: python + import myDotaModule from steam import SteamClient + from steam.core.msg import GCMsgHdrProto from steam.client.gc import GameCoordinator client = SteamClient() + + # login logic etc + gc = GameCoordinator(client, 570) @gc.on(None) @@ -15,8 +24,19 @@ Example usage for messages to the Dota 2 GC. @gc.on(4004) # EMsgGCClientWelcome def handle_client_welcome(header, body): - passs + message = myDotaModule.gcsdk_gcmessages_pb2.CMsgClientWelcome() + message.ParseFromString(body) + + # indicate to steam that we are playing Dota 2 + client.games_played([570]) + # send client hello + header = GCMsgHdrProto(4006) # EMsgGCClientHello + body = myDotaModule.gcsdk_gcmessages_pb2.CMsgClientHello() + gc.send(header, body.SerializeToString()) + +The above code assumes that we have a ``myDotaModule`` that contains the appropriate +data structures, which can be used to (de)serialize messages. For example, protobufs. """ import logging import gevent @@ -29,12 +49,19 @@ from steam.core.msg import GCMsgHdr, GCMsgHdrProto, MsgProto class GameCoordinator(EventEmitter): """ - GameCoordinator is used to proxy messages from/to GC + ``GameCoordinator`` is used to proxy messages from/to GC :param steam_client: steam client instance :type steam_client: :class:`steam.client.SteamClient` :param app_id: app id of the application :type app_id: :class:`int` + + Incoming messages are emitted as events using their ``EMsg`` as an event identifier. + + :param header: message header + :type header: :class:`steam.core.msg.GCMsgHdr` + :param body: raw message body + :type body: :class:`bytes` """ def __init__(self, steam_client, app_id):