<commit_before>"""
:class:`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.

.. code:: python

    import myDotaModule
    from steam 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])

The above code assumes that we have a ``myDotaModule`` that contains the appropriate
protobufs needed to (de)serialize message for communication with GC.
"""
import logging
import gevent
from eventemitter import EventEmitter
from steam.util import set_proto_bit, clear_proto_bit, is_proto
from steam.enums.emsg import EMsg
from steam.enums import EResult
from steam.core.msg import GCMsgHdr, GCMsgHdrProto, MsgProto
from steam.client import SteamClient


class GameCoordinator(EventEmitter):
    """
    ``GameCoordinator`` is used to proxy messages from/to GC
<commit_msg>add missing line in GC example<commit_after>"""
:class:`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.

.. code:: python

    import myDotaModule
    from steam 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.
"""
import logging
import gevent
from eventemitter import EventEmitter
from steam.util import set_proto_bit, clear_proto_bit, is_proto
from steam.enums.emsg import EMsg
from steam.enums import EResult
from steam.core.msg import GCMsgHdr, GCMsgHdrProto, MsgProto
from steam.client import SteamClient


class GameCoordinator(EventEmitter):
    """
    ``GameCoordinator`` is used to proxy messages from/to GC

{'fraction_non_alphanumeric': 0.06818830242510698, 'fraction_numerical': 0.009700427960057061, 'mean_word_length': 3.506426735218509, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7106102', 'n_tokens_mistral': 1023, 'n_tokens_neox': 976, 'n_words': 316}