revert PrintJSON to use key data, to match with documented behaviour

This commit is contained in:
Fabian Dill 2021-03-02 22:36:50 +01:00
parent 7871555620
commit 0917f21384
3 changed files with 7 additions and 3 deletions

View File

@ -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']}")

View File

@ -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]:

View File

@ -274,4 +274,4 @@ class Hint(typing.NamedTuple):
else:
add_json_text(parts, ".")
return {"cmd": "PrintJSON", "text": parts, "type": "hint"}
return {"cmd": "PrintJSON", "data": parts, "type": "hint"}