From 8e35372aad2957a3989bac11b8490404194aa6ef Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 22 Oct 2021 04:46:00 +0200 Subject: [PATCH] Network: add RoomInfo -> Games Allows clients to only download relevant parts of the datapackage, or to keep ID lookups per-game, and for Bounce to tell if there will be a receiving end. --- MultiServer.py | 1 + docs/network protocol.md | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/MultiServer.py b/MultiServer.py index c84664ac..322337ca 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -489,6 +489,7 @@ async def on_client_connected(ctx: Context, client: Client): 'cmd': 'RoomInfo', 'password': bool(ctx.password), 'players': players, + 'games': [ctx.games[x] for x in range(1, len(ctx.games)+1)], # tags are for additional features in the communication. # Name them by feature or fork, as you feel is appropriate. 'tags': ctx.tags, diff --git a/docs/network protocol.md b/docs/network protocol.md index d764e4bf..1db2b238 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -57,8 +57,9 @@ Sent to clients when they connect to an Archipelago server. | hint_cost | int | The amount of points it costs to receive a hint from the server. | | location_check_points | int | The amount of hint points you receive per item/location check completed. || | players | list\[NetworkPlayer\] | Sent only if the client is properly authenticated (see [Archipelago Connection Handshake](#Archipelago-Connection-Handshake)). Information on the players currently connected to the server. See [NetworkPlayer](#NetworkPlayer) for more details. | +| games | list\[str\] | sorted list of game names for the players, so first player's game will be games\[0\]. Matches game names in datapackage. | | datapackage_version | int | Data version of the [data package](#Data Package Contents) the server will send. Used to update the client's (optional) local cache. | -| datapackage_versions | dict[str, int] | Data versions of the individual games' data packages the server will send. | +| datapackage_versions | dict\[str, int\] | Data versions of the individual games' data packages the server will send. | | seed_name | str | uniquely identifying name of this generation | #### forfeit @@ -247,7 +248,7 @@ Requests the data package from the server. Does not require client authenticatio #### Arguments | Name | Type | Notes | | ------ | ----- | ------ | -| exclusions | list[str] | Optional. If specified, will not send back the specified data. Such as, ["Factorio"] -> Datapackage without Factorio data.| +| exclusions | list\[str\] | Optional. If specified, will not send back the specified data. Such as, \["Factorio"\] -> Datapackage without Factorio data.| ### Bounce Send this message to the server, tell it which clients should receive the message and @@ -256,9 +257,9 @@ the server will forward the message to all those targets to which any one requir #### Arguments | Name | Type | Notes | | ------ | ----- | ------ | -| games | list[str] | Optional. Game names that should receive this message | -| slots | list[int] | Optional. Player IDs that should receive this message | -| tags | list[str] | Optional. Client tags that should receive this message | +| games | list\[str\] | Optional. Game names that should receive this message | +| slots | list\[int\] | Optional. Player IDs that should receive this message | +| tags | list\[str\] | Optional. Client tags that should receive this message | | data | dict | Any data you want to send |