Skip to content

Implement two way communication between client and game #1068

@louvenarde

Description

@louvenarde

Currently, the client doesnt send information to the game very well, it can only do so with command line arguments or the initial game start.

To fix this we can use the CreateLobby command currently used by the game to process json tables, containing information we want the game to have, such as player information, and arbitrary content really. So this is both extremely useful and extremely important.

The client already has some functionality to send the game messages, as seen in game_session.py
so what needs to happen is for the code to be expanded to include a general communication feature as well.

This can be done with

self._game_connection.send("CreateLobby",
                           self.init_mode,
                           -1,
                           messagecontent)

where messagecontent is a json table.

The game currently is set up to process json tables when they are sent to a port of -1, but it currently doesnt do anything with those messages should they arrive.
sending the game messages on that port will allow it to recieve data, and its up to whichever feature needs it to decide how to process that.

The json table should be structured as follows:
Messages are JSON strings containing two fields:
command_id: A string identifying the type of message. This string is used as a key into
MESSAGE_HANDLERS (defined in the game code) to find the function to use to process this message.
arguments: An array of arguments that should be passed to the handler function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions