From 0917f21384069e6b16d4d150a2024a091d2c1016 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 2 Mar 2021 22:36:50 +0100 Subject: [PATCH] revert PrintJSON to use key data, to match with documented behaviour --- MultiClient.py | 2 +- MultiServer.py | 6 +++++- NetUtils.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MultiClient.py b/MultiClient.py index a6162966..6f9bc2e6 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -945,7 +945,7 @@ async def process_server_cmd(ctx: Context, args: dict): logger.info(args["text"]) elif cmd == 'PrintJSON': - logger.info(ctx.jsontotextparser(args["text"])) + logger.info(ctx.jsontotextparser(args["data"])) elif cmd == 'InvalidArguments': logger.warning(f"Invalid Arguments: {args['text']}") diff --git a/MultiServer.py b/MultiServer.py index 7089eb5f..732171fc 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -332,14 +332,18 @@ async def server(websocket, path, ctx: Context): ctx.endpoints.append(client) try: + logging.info("Incoming") await on_client_connected(ctx, client) + logging.info("Sent Room Info") async for data in websocket: + logging.info(data) for msg in decode(data): await process_client_cmd(ctx, client, msg) except Exception as e: if not isinstance(e, websockets.WebSocketException): logging.exception(e) finally: + logging.info("Disconnected") await ctx.disconnect(client) @@ -530,7 +534,7 @@ def json_format_send_event(net_item: NetworkItem, receiving_player: int): NetUtils.add_json_text(parts, net_item.location, type=NetUtils.JSONTypes.location_id) NetUtils.add_json_text(parts, ")") - return {"cmd": "PrintJSON", "text": parts, "type": "ItemSend", + return {"cmd": "PrintJSON", "data": parts, "type": "ItemSend", "receiving": receiving_player, "sending": net_item.player} def get_intended_text(input_text: str, possible_answers: typing.Iterable[str]= console_names) -> typing.Tuple[str, bool, str]: diff --git a/NetUtils.py b/NetUtils.py index 1a070621..8288c00a 100644 --- a/NetUtils.py +++ b/NetUtils.py @@ -274,4 +274,4 @@ class Hint(typing.NamedTuple): else: add_json_text(parts, ".") - return {"cmd": "PrintJSON", "text": parts, "type": "hint"} \ No newline at end of file + return {"cmd": "PrintJSON", "data": parts, "type": "hint"} \ No newline at end of file