From af7f5cf19cf1b2222d639405aaab3798b75e5716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Charvet=20=E9=BB=91=E7=93=9C?= Date: Wed, 11 Sep 2024 19:56:40 +0100 Subject: [PATCH] Add matchmaking/cancelled event --- docs/schema/matchmaking.md | 115 +++++++++++++++++++----- docs/schema/system.md | 12 +-- docs/schema/user.md | 56 ++++++------ schema/compiled.json | 21 +++++ schema/matchmaking/cancelled/event.json | 23 +++++ src/schema/matchmaking/README.md | 6 +- src/schema/matchmaking/cancelled.ts | 15 ++++ 7 files changed, 191 insertions(+), 57 deletions(-) create mode 100644 schema/matchmaking/cancelled/event.json create mode 100644 src/schema/matchmaking/cancelled.ts diff --git a/docs/schema/matchmaking.md b/docs/schema/matchmaking.md index 3737544..7dff2ea 100644 --- a/docs/schema/matchmaking.md +++ b/docs/schema/matchmaking.md @@ -9,12 +9,16 @@ The matchmaking cycle works as follows: 3. The server can send periodic updates about the status of the search as a [queueUpdate](#queueupdate) event. 4. When a match is found, the server should send a [found](#found) event along with the id of the queue of the found match. 5. Clients can then ready up by sending a [ready](#ready) request. The number of readied players should be sent to clients via the [readyUpdate](#readyupdate) event. -6. To cancel queueing, or to decline a found match, clients should send a [cancel](#cancel) request. +6. To cancel queueing, or to decline a found match, clients should send a [cancel](#cancel) request. After a successful `cancel` response, the server will also send a [cancelled](#cancelled) event. 7. If a client fails to ready up for a found match, the server should send a [lost](#lost) event, and the queueing phase should resume. 8. Once all players are ready, the server should send a [autohost/battleStart](#autohost/battleStart) request to a suitable autohost client. If the autohost doesn't respond quickly, or if it sends a failed response, the server should repeat this step. -9. Once the autohost has successfully started the battle, the server should then send [battle/battleStart](#battle/battleStart) requests to the users. +9. Once the autohost has successfully started the battle, the server should then send [battle/battleStart](#battle/battleStart) requests to the users. + +The server may send [matchmaking/cancelled](#cancelled) event at any point after the client sent a [queue](#queue) request with a reason. This means the client has been booted out the matchmaking system. It can happen for example when a party member leaves, or in case of a server error that needs to reset the matchmaking state. This event is also sent after a successful [cancel](#cancel) request. + --- - [cancel](#cancel) +- [cancelled](#cancelled) - [found](#found) - [foundUpdate](#foundupdate) - [list](#list) @@ -157,6 +161,75 @@ Possible Failed Reasons: `not_queued`, `internal_error`, `unauthorized`, `invali --- +## Cancelled + +Server may send this event at any point when the user is queuing to indicate that the user has been booted out the matchmaking system. + +- Endpoint Type: **Event** +- Source: **Server** +- Target: **User** +- Required Scopes: `tachyon.lobby` + +### Event + +
+JSONSchema + +```json +{ + "title": "MatchmakingCancelledEvent", + "tachyon": { + "source": "server", + "target": "user", + "scopes": ["tachyon.lobby"] + }, + "type": "object", + "properties": { + "type": { "const": "event" }, + "messageId": { "type": "string" }, + "commandId": { "const": "matchmaking/cancelled" }, + "data": { + "title": "MatchmakingCancelledEventData", + "type": "object", + "properties": { "reason": { "type": "string" } }, + "required": ["reason"] + } + }, + "required": ["type", "messageId", "commandId", "data"] +} + +``` +
+ +
+Example + +```json +{ + "type": "event", + "messageId": "voluptate ullamco", + "commandId": "matchmaking/cancelled", + "data": { + "reason": "voluptate ullamco" + } +} +``` +
+ +#### TypeScript Definition +```ts +export interface MatchmakingCancelledEvent { + type: "event"; + messageId: string; + commandId: "matchmaking/cancelled"; + data: MatchmakingCancelledEventData; +} +export interface MatchmakingCancelledEventData { + reason: string; +} +``` +--- + ## Found Server should send this when there are enough queued players to form a valid battle that meets their criteria. Clients should then send [ready](#ready). @@ -206,11 +279,11 @@ Server should send this when there are enough queued players to form a valid bat ```json { "type": "event", - "messageId": "voluptate ullamco", + "messageId": "in exercitation", "commandId": "matchmaking/found", "data": { - "queueId": "voluptate ullamco", - "timeoutMs": -50000000 + "queueId": "in exercitation", + "timeoutMs": -48000000 } } ``` @@ -277,10 +350,10 @@ Server should send this when players ready up using [ready](#ready). ```json { "type": "event", - "messageId": "in exercitation", + "messageId": "in nostrud", "commandId": "matchmaking/foundUpdate", "data": { - "readyCount": -48000000 + "readyCount": -46000000 } } ``` @@ -340,7 +413,7 @@ Returns all available matchmaking playlists. ```json { "type": "request", - "messageId": "in nostrud", + "messageId": "consequat quis", "commandId": "matchmaking/list" } ``` @@ -458,7 +531,7 @@ export interface MatchmakingListRequest { ```json { "type": "response", - "messageId": "consequat quis", + "messageId": "commodo laborum", "commandId": "matchmaking/list", "status": "success", "data": { @@ -546,7 +619,7 @@ Sent when a found match gets disbanded because a client failed to ready up. ```json { "type": "event", - "messageId": "commodo laborum", + "messageId": "nisi deserunt", "commandId": "matchmaking/lost" } ``` @@ -614,12 +687,12 @@ Queue up for matchmaking. Should cancel the previous queue if already in one. ```json { "type": "request", - "messageId": "nisi deserunt", + "messageId": "nisi qui", "commandId": "matchmaking/queue", "data": { "queues": [ - "nisi deserunt", - "nisi deserunt" + "nisi qui", + "nisi qui" ] } } @@ -698,7 +771,7 @@ export interface MatchmakingQueueRequestData { ```json { "type": "response", - "messageId": "nisi qui", + "messageId": "laboris non", "commandId": "matchmaking/queue", "status": "success" } @@ -764,10 +837,10 @@ Contains some info about the state of the current queue. ```json { "type": "event", - "messageId": "laboris non", + "messageId": "ullamco occaecat", "commandId": "matchmaking/queueUpdate", "data": { - "playersQueued": "laboris non" + "playersQueued": "ullamco occaecat" } } ``` @@ -827,7 +900,7 @@ Clients should send this when they are ready to proceed with the found match. If ```json { "type": "request", - "messageId": "ullamco occaecat", + "messageId": "reprehenderit Lorem", "commandId": "matchmaking/ready" } ``` @@ -899,7 +972,7 @@ export interface MatchmakingReadyRequest { ```json { "type": "response", - "messageId": "reprehenderit Lorem", + "messageId": "dolor Lorem", "commandId": "matchmaking/ready", "status": "success" } @@ -968,11 +1041,11 @@ Sent when a client in a found match readies up. ```json { "type": "event", - "messageId": "dolor Lorem", + "messageId": "Duis Lorem", "commandId": "matchmaking/readyUpdate", "data": { - "readyMax": -30000000, - "readyCurrent": -30000000 + "readyMax": -28000000, + "readyCurrent": -28000000 } } ``` diff --git a/docs/schema/system.md b/docs/schema/system.md index 7f83a7f..27b91bb 100644 --- a/docs/schema/system.md +++ b/docs/schema/system.md @@ -52,10 +52,10 @@ Ask the server to terminate the connection. ```json { "type": "request", - "messageId": "Duis Lorem", + "messageId": "consequat Lorem", "commandId": "system/disconnect", "data": { - "reason": "Duis Lorem" + "reason": "consequat Lorem" } } ``` @@ -130,7 +130,7 @@ export interface SystemDisconnectRequestData { ```json { "type": "response", - "messageId": "consequat Lorem", + "messageId": "commodo Lorem", "commandId": "system/disconnect", "status": "success" } @@ -190,7 +190,7 @@ Get server stats such as user count. ```json { "type": "request", - "messageId": "commodo Lorem", + "messageId": "ut Lorem", "commandId": "system/serverStats" } ``` @@ -267,11 +267,11 @@ export interface SystemServerStatsRequest { ```json { "type": "response", - "messageId": "ut Lorem", + "messageId": "occaecat Lorem in", "commandId": "system/serverStats", "status": "success", "data": { - "userCount": -22000000 + "userCount": -20000000 } } ``` diff --git a/docs/schema/user.md b/docs/schema/user.md index b3af82a..1337f2c 100644 --- a/docs/schema/user.md +++ b/docs/schema/user.md @@ -120,59 +120,59 @@ Sent by the server to inform the client when subscribed users get updated in som ```json { "type": "event", - "messageId": "occaecat Lorem in", + "messageId": "pariatur Lorem reprehenderit", "commandId": "user/updated", "data": { "users": [ { - "occaecatff": -19999999.999999955, + "pariaturff": -17999999.999999955, "userId": "f47a7e1e-4b2f-4d3d-3f3c-1f0f0e4b7e1e", - "username": "occaecat Lorem in", + "username": "pariatur Lorem reprehenderit", "scopes": [ - "occaecat Lorem in", - "occaecat Lorem in", - "occaecat Lorem in" + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit" ], - "countryCode": "occaecat Lorem in", + "countryCode": "pariatur Lorem reprehenderit", "status": "menu", "outgoingFriendRequestIds": [ - "occaecat Lorem in", - "occaecat Lorem in", - "occaecat Lorem in" + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit" ] }, { - "occaecatff": -19999999.999999955, + "pariaturff": -17999999.999999955, "userId": "f47a7e1e-4b2f-4d3d-3f3c-1f0f0e4b7e1e", - "username": "occaecat Lorem in", + "username": "pariatur Lorem reprehenderit", "scopes": [ - "occaecat Lorem in", - "occaecat Lorem in", - "occaecat Lorem in" + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit" ], - "countryCode": "occaecat Lorem in", + "countryCode": "pariatur Lorem reprehenderit", "status": "menu", "outgoingFriendRequestIds": [ - "occaecat Lorem in", - "occaecat Lorem in", - "occaecat Lorem in" + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit" ] }, { - "occaecatff": -19999999.999999955, + "pariaturff": -17999999.999999955, "userId": "f47a7e1e-4b2f-4d3d-3f3c-1f0f0e4b7e1e", - "username": "occaecat Lorem in", + "username": "pariatur Lorem reprehenderit", "scopes": [ - "occaecat Lorem in", - "occaecat Lorem in", - "occaecat Lorem in" + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit" ], - "countryCode": "occaecat Lorem in", + "countryCode": "pariatur Lorem reprehenderit", "status": "menu", "outgoingFriendRequestIds": [ - "occaecat Lorem in", - "occaecat Lorem in", - "occaecat Lorem in" + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit", + "pariatur Lorem reprehenderit" ] } ] diff --git a/schema/compiled.json b/schema/compiled.json index fecf07d..ab98ebb 100644 --- a/schema/compiled.json +++ b/schema/compiled.json @@ -1331,6 +1331,27 @@ } ] }, + { + "title": "MatchmakingCancelledEvent", + "tachyon": { + "source": "server", + "target": "user", + "scopes": ["tachyon.lobby"] + }, + "type": "object", + "properties": { + "type": { "const": "event" }, + "messageId": { "type": "string" }, + "commandId": { "const": "matchmaking/cancelled" }, + "data": { + "title": "MatchmakingCancelledEventData", + "type": "object", + "properties": { "reason": { "type": "string" } }, + "required": ["reason"] + } + }, + "required": ["type", "messageId", "commandId", "data"] + }, { "title": "MatchmakingFoundEvent", "tachyon": { diff --git a/schema/matchmaking/cancelled/event.json b/schema/matchmaking/cancelled/event.json new file mode 100644 index 0000000..f242126 --- /dev/null +++ b/schema/matchmaking/cancelled/event.json @@ -0,0 +1,23 @@ +{ + "$id": "https://schema.beyondallreason.dev/tachyon/matchmaking/cancelled/event.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MatchmakingCancelledEvent", + "tachyon": { + "source": "server", + "target": "user", + "scopes": ["tachyon.lobby"] + }, + "type": "object", + "properties": { + "type": { "const": "event" }, + "messageId": { "type": "string" }, + "commandId": { "const": "matchmaking/cancelled" }, + "data": { + "title": "MatchmakingCancelledEventData", + "type": "object", + "properties": { "reason": { "type": "string" } }, + "required": ["reason"] + } + }, + "required": ["type", "messageId", "commandId", "data"] +} diff --git a/src/schema/matchmaking/README.md b/src/schema/matchmaking/README.md index 3e5e4e8..afa0518 100644 --- a/src/schema/matchmaking/README.md +++ b/src/schema/matchmaking/README.md @@ -5,7 +5,9 @@ The matchmaking cycle works as follows: 3. The server can send periodic updates about the status of the search as a [queueUpdate](#queueupdate) event. 4. When a match is found, the server should send a [found](#found) event along with the id of the queue of the found match. 5. Clients can then ready up by sending a [ready](#ready) request. The number of readied players should be sent to clients via the [readyUpdate](#readyupdate) event. -6. To cancel queueing, or to decline a found match, clients should send a [cancel](#cancel) request. +6. To cancel queueing, or to decline a found match, clients should send a [cancel](#cancel) request. After a successful `cancel` response, the server will also send a [cancelled](#cancelled) event. 7. If a client fails to ready up for a found match, the server should send a [lost](#lost) event, and the queueing phase should resume. 8. Once all players are ready, the server should send a [autohost/battleStart](#autohost/battleStart) request to a suitable autohost client. If the autohost doesn't respond quickly, or if it sends a failed response, the server should repeat this step. -9. Once the autohost has successfully started the battle, the server should then send [battle/battleStart](#battle/battleStart) requests to the users. \ No newline at end of file +9. Once the autohost has successfully started the battle, the server should then send [battle/battleStart](#battle/battleStart) requests to the users. + +The server may send [matchmaking/cancelled](#cancelled) event at any point after the client sent a [queue](#queue) request with a reason. This means the client has been booted out the matchmaking system. It can happen for example when a party member leaves, or in case of a server error that needs to reset the matchmaking state. This event is also sent after a successful [cancel](#cancel) request. diff --git a/src/schema/matchmaking/cancelled.ts b/src/schema/matchmaking/cancelled.ts new file mode 100644 index 0000000..dbf371f --- /dev/null +++ b/src/schema/matchmaking/cancelled.ts @@ -0,0 +1,15 @@ +import { Type } from "@sinclair/typebox"; + +import { defineEndpoint } from "@/generator-helpers.js"; + +export default defineEndpoint({ + source: "server", + target: "user", + description: + "Server may send this event at any point when the user is queuing to indicate that the user has been booted out the matchmaking system.", + event: { + data: Type.Object({ + reason: Type.String(), + }), + }, +});