Skip to content

Commit 36ccacc

Browse files
authored
Add some simple player status in lobby (#84)
This would then enable the "start" command to only work when all players are ready (for later)
1 parent 46fe9d7 commit 36ccacc

8 files changed

Lines changed: 361 additions & 3 deletions

File tree

docs/schema/lobby.md

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ in that spot and update its state through [lobby/updated](#updated).
9999
A member simply spectating and not waiting to play will have a null `joinQueuePosition`.
100100
To leave an ally team or the join queue and become a spectator, a user should use [lobby/spectate](#spectate).
101101

102+
Clients can send a [lobby/updateClientStatus](#updateClientStatus) request to notify others if they are ready
103+
and if they need to download some assets, like engine, map or game. When a user becomes a player (at lobby creation,
104+
through `joinAllyTeam` or with the join queue), the server will automatically assign them a default status
105+
`{"isReady": false, "assetStatus": "ready"}`. If this is incorrect the client should send a request to correct it.
106+
102107

103108
### Lobby updates
104109

@@ -136,6 +141,7 @@ In practice, this event should rarely be seen.
136141
- [unsubscribeList](#unsubscribelist)
137142
- [update](#update)
138143
- [updateBot](#updatebot)
144+
- [updateClientStatus](#updateclientstatus)
139145
- [updated](#updated)
140146
- [voteEnded](#voteended)
141147
- [voteSubmit](#votesubmit)
@@ -2965,6 +2971,156 @@ Possible Failed Reasons: `not_in_lobby`, `invalid_bot`, `internal_error`, `unaut
29652971

29662972
---
29672973

2974+
## UpdateClientStatus
2975+
2976+
Update the player's status
2977+
2978+
- Endpoint Type: **Request** -> **Response**
2979+
- Source: **User**
2980+
- Target: **Server**
2981+
- Required Scopes: `tachyon.lobby`
2982+
2983+
### Request
2984+
2985+
<details>
2986+
<summary>JSONSchema</summary>
2987+
2988+
```json
2989+
{
2990+
"title": "LobbyUpdateClientStatusRequest",
2991+
"tachyon": {
2992+
"source": "user",
2993+
"target": "server",
2994+
"scopes": ["tachyon.lobby"]
2995+
},
2996+
"type": "object",
2997+
"properties": {
2998+
"type": { "const": "request" },
2999+
"messageId": { "type": "string" },
3000+
"commandId": { "const": "lobby/updateClientStatus" },
3001+
"data": {
3002+
"title": "LobbyUpdateClientStatusRequestData",
3003+
"type": "object",
3004+
"properties": {
3005+
"isReady": { "type": "boolean" },
3006+
"assetStatus": { "enum": ["missing", "downloading", "ready"] }
3007+
}
3008+
}
3009+
},
3010+
"required": ["type", "messageId", "commandId", "data"]
3011+
}
3012+
3013+
```
3014+
</details>
3015+
3016+
<details>
3017+
<summary>Example</summary>
3018+
3019+
```json
3020+
{
3021+
"type": "request",
3022+
"messageId": "do",
3023+
"commandId": "lobby/updateClientStatus",
3024+
"data": {
3025+
"isReady": false,
3026+
"assetStatus": "missing"
3027+
}
3028+
}
3029+
```
3030+
</details>
3031+
3032+
#### TypeScript Definition
3033+
```ts
3034+
export interface LobbyUpdateClientStatusRequest {
3035+
type: "request";
3036+
messageId: string;
3037+
commandId: "lobby/updateClientStatus";
3038+
data: LobbyUpdateClientStatusRequestData;
3039+
}
3040+
export interface LobbyUpdateClientStatusRequestData {
3041+
isReady?: boolean;
3042+
assetStatus?: "missing" | "downloading" | "ready";
3043+
}
3044+
```
3045+
### Response
3046+
3047+
<details>
3048+
<summary>JSONSchema</summary>
3049+
3050+
```json
3051+
{
3052+
"title": "LobbyUpdateClientStatusResponse",
3053+
"tachyon": {
3054+
"source": "server",
3055+
"target": "user",
3056+
"scopes": ["tachyon.lobby"]
3057+
},
3058+
"anyOf": [
3059+
{
3060+
"title": "LobbyUpdateClientStatusOkResponse",
3061+
"type": "object",
3062+
"properties": {
3063+
"type": { "const": "response" },
3064+
"messageId": { "type": "string" },
3065+
"commandId": { "const": "lobby/updateClientStatus" },
3066+
"status": { "const": "success" }
3067+
},
3068+
"required": ["type", "messageId", "commandId", "status"]
3069+
},
3070+
{
3071+
"title": "LobbyUpdateClientStatusFailResponse",
3072+
"type": "object",
3073+
"properties": {
3074+
"type": { "const": "response" },
3075+
"messageId": { "type": "string" },
3076+
"commandId": { "const": "lobby/updateClientStatus" },
3077+
"status": { "const": "failed" },
3078+
"reason": {
3079+
"enum": [
3080+
"not_in_lobby",
3081+
"not_a_player",
3082+
"internal_error",
3083+
"unauthorized",
3084+
"invalid_request",
3085+
"command_unimplemented"
3086+
]
3087+
},
3088+
"details": { "type": "string" }
3089+
},
3090+
"required": ["type", "messageId", "commandId", "status", "reason"]
3091+
}
3092+
]
3093+
}
3094+
3095+
```
3096+
</details>
3097+
3098+
<details>
3099+
<summary>Example</summary>
3100+
3101+
```json
3102+
{
3103+
"type": "response",
3104+
"messageId": "in esse est cillum irure",
3105+
"commandId": "lobby/updateClientStatus",
3106+
"status": "success"
3107+
}
3108+
```
3109+
</details>
3110+
3111+
#### TypeScript Definition
3112+
```ts
3113+
export interface LobbyUpdateClientStatusOkResponse {
3114+
type: "response";
3115+
messageId: string;
3116+
commandId: "lobby/updateClientStatus";
3117+
status: "success";
3118+
}
3119+
```
3120+
Possible Failed Reasons: `not_in_lobby`, `not_a_player`, `internal_error`, `unauthorized`, `invalid_request`, `command_unimplemented`
3121+
3122+
---
3123+
29683124
## Updated
29693125

29703126
Sent by the server whenever something in the lobby changes. Uses json patch (RFC-7386)
@@ -3057,7 +3213,15 @@ Sent by the server whenever something in the lobby changes. Uses json patch (RFC
30573213
},
30583214
"allyTeam": { "type": "string" },
30593215
"team": { "type": "string" },
3060-
"player": { "type": "string" }
3216+
"player": { "type": "string" },
3217+
"isReady": { "type": "boolean" },
3218+
"assetStatus": {
3219+
"enum": [
3220+
"missing",
3221+
"downloading",
3222+
"ready"
3223+
]
3224+
}
30613225
},
30623226
"required": ["id"]
30633227
},
@@ -3340,6 +3504,8 @@ export interface LobbyUpdatedEventData {
33403504
allyTeam?: string;
33413505
team?: string;
33423506
player?: string;
3507+
isReady?: boolean;
3508+
assetStatus?: "missing" | "downloading" | "ready";
33433509
} | null;
33443510
};
33453511
spectators?: {

schema/compiled.json

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3387,6 +3387,80 @@
33873387
}
33883388
]
33893389
},
3390+
{
3391+
"title": "LobbyUpdateClientStatusRequest",
3392+
"tachyon": {
3393+
"source": "user",
3394+
"target": "server",
3395+
"scopes": ["tachyon.lobby"]
3396+
},
3397+
"type": "object",
3398+
"properties": {
3399+
"type": { "const": "request" },
3400+
"messageId": { "type": "string" },
3401+
"commandId": { "const": "lobby/updateClientStatus" },
3402+
"data": {
3403+
"title": "LobbyUpdateClientStatusRequestData",
3404+
"type": "object",
3405+
"properties": {
3406+
"isReady": { "type": "boolean" },
3407+
"assetStatus": {
3408+
"enum": ["missing", "downloading", "ready"]
3409+
}
3410+
}
3411+
}
3412+
},
3413+
"required": ["type", "messageId", "commandId", "data"]
3414+
},
3415+
{
3416+
"title": "LobbyUpdateClientStatusResponse",
3417+
"tachyon": {
3418+
"source": "server",
3419+
"target": "user",
3420+
"scopes": ["tachyon.lobby"]
3421+
},
3422+
"anyOf": [
3423+
{
3424+
"title": "LobbyUpdateClientStatusOkResponse",
3425+
"type": "object",
3426+
"properties": {
3427+
"type": { "const": "response" },
3428+
"messageId": { "type": "string" },
3429+
"commandId": { "const": "lobby/updateClientStatus" },
3430+
"status": { "const": "success" }
3431+
},
3432+
"required": ["type", "messageId", "commandId", "status"]
3433+
},
3434+
{
3435+
"title": "LobbyUpdateClientStatusFailResponse",
3436+
"type": "object",
3437+
"properties": {
3438+
"type": { "const": "response" },
3439+
"messageId": { "type": "string" },
3440+
"commandId": { "const": "lobby/updateClientStatus" },
3441+
"status": { "const": "failed" },
3442+
"reason": {
3443+
"enum": [
3444+
"not_in_lobby",
3445+
"not_a_player",
3446+
"internal_error",
3447+
"unauthorized",
3448+
"invalid_request",
3449+
"command_unimplemented"
3450+
]
3451+
},
3452+
"details": { "type": "string" }
3453+
},
3454+
"required": [
3455+
"type",
3456+
"messageId",
3457+
"commandId",
3458+
"status",
3459+
"reason"
3460+
]
3461+
}
3462+
]
3463+
},
33903464
{
33913465
"title": "LobbyUpdatedEvent",
33923466
"tachyon": {
@@ -3468,7 +3542,17 @@
34683542
"type": "string"
34693543
},
34703544
"team": { "type": "string" },
3471-
"player": { "type": "string" }
3545+
"player": { "type": "string" },
3546+
"isReady": {
3547+
"type": "boolean"
3548+
},
3549+
"assetStatus": {
3550+
"enum": [
3551+
"missing",
3552+
"downloading",
3553+
"ready"
3554+
]
3555+
}
34723556
},
34733557
"required": ["id"]
34743558
},
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$id": "https://schema.beyondallreason.dev/tachyon/lobby/updateClientStatus/request.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"title": "LobbyUpdateClientStatusRequest",
5+
"tachyon": {
6+
"source": "user",
7+
"target": "server",
8+
"scopes": ["tachyon.lobby"]
9+
},
10+
"type": "object",
11+
"properties": {
12+
"type": { "const": "request" },
13+
"messageId": { "type": "string" },
14+
"commandId": { "const": "lobby/updateClientStatus" },
15+
"data": {
16+
"title": "LobbyUpdateClientStatusRequestData",
17+
"type": "object",
18+
"properties": {
19+
"isReady": { "type": "boolean" },
20+
"assetStatus": { "enum": ["missing", "downloading", "ready"] }
21+
}
22+
}
23+
},
24+
"required": ["type", "messageId", "commandId", "data"]
25+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$id": "https://schema.beyondallreason.dev/tachyon/lobby/updateClientStatus/response.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"title": "LobbyUpdateClientStatusResponse",
5+
"tachyon": {
6+
"source": "server",
7+
"target": "user",
8+
"scopes": ["tachyon.lobby"]
9+
},
10+
"anyOf": [
11+
{
12+
"title": "LobbyUpdateClientStatusOkResponse",
13+
"type": "object",
14+
"properties": {
15+
"type": { "const": "response" },
16+
"messageId": { "type": "string" },
17+
"commandId": { "const": "lobby/updateClientStatus" },
18+
"status": { "const": "success" }
19+
},
20+
"required": ["type", "messageId", "commandId", "status"]
21+
},
22+
{
23+
"title": "LobbyUpdateClientStatusFailResponse",
24+
"type": "object",
25+
"properties": {
26+
"type": { "const": "response" },
27+
"messageId": { "type": "string" },
28+
"commandId": { "const": "lobby/updateClientStatus" },
29+
"status": { "const": "failed" },
30+
"reason": {
31+
"enum": [
32+
"not_in_lobby",
33+
"not_a_player",
34+
"internal_error",
35+
"unauthorized",
36+
"invalid_request",
37+
"command_unimplemented"
38+
]
39+
},
40+
"details": { "type": "string" }
41+
},
42+
"required": ["type", "messageId", "commandId", "status", "reason"]
43+
}
44+
]
45+
}

schema/lobby/updated/event.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@
7777
},
7878
"allyTeam": { "type": "string" },
7979
"team": { "type": "string" },
80-
"player": { "type": "string" }
80+
"player": { "type": "string" },
81+
"isReady": { "type": "boolean" },
82+
"assetStatus": {
83+
"enum": [
84+
"missing",
85+
"downloading",
86+
"ready"
87+
]
88+
}
8189
},
8290
"required": ["id"]
8391
},

0 commit comments

Comments
 (0)