From 5cdd9a59cc7c36fb640e340f7356b0200050847b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Charvet=20=E9=BB=91=E7=93=9C?= Date: Mon, 2 Sep 2024 19:57:39 +0100 Subject: [PATCH] Revert "Change join queue request for only one queue (#31)" This reverts commit 365d9e2fd226d6cd984368ece16ade949d4b172d. --- docs/schema/matchmaking.md | 24 ++++++++++++++++-------- schema/compiled.json | 10 ++++++++-- schema/matchmaking/queue/request.json | 10 ++++++++-- src/schema/matchmaking/README.md | 4 ++-- src/schema/matchmaking/queue.ts | 4 ++-- test/cjs/validator.test.cts | 6 +++--- test/esm/validator.test.mts | 4 ++-- 7 files changed, 41 insertions(+), 21 deletions(-) diff --git a/docs/schema/matchmaking.md b/docs/schema/matchmaking.md index 99c2cab..3737544 100644 --- a/docs/schema/matchmaking.md +++ b/docs/schema/matchmaking.md @@ -5,15 +5,14 @@ The matchmaking cycle works as follows: 1. Clients should first retrieve a list of all the available queues from the server using [list](#list). -2. Clients should then queue for one or more of these queues by sending the queue id in several [queue](#queue) requests. +2. Clients should then queue for one or more of these queues by sending an array of the queue ids in a [queue](#queue) request. 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. 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. --- - [cancel](#cancel) - [found](#found) @@ -565,7 +564,7 @@ export interface MatchmakingLostEvent { ## Queue -Queue up for matchmaking on the specific queue id. +Queue up for matchmaking. Should cancel the previous queue if already in one. - Endpoint Type: **Event** - Source: **User** @@ -593,8 +592,14 @@ Queue up for matchmaking on the specific queue id. "data": { "title": "MatchmakingQueueRequestData", "type": "object", - "properties": { "queue": { "type": "string" } }, - "required": ["queue"] + "properties": { + "queues": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1 + } + }, + "required": ["queues"] } }, "required": ["type", "messageId", "commandId", "data"] @@ -612,7 +617,10 @@ Queue up for matchmaking on the specific queue id. "messageId": "nisi deserunt", "commandId": "matchmaking/queue", "data": { - "queue": "nisi deserunt" + "queues": [ + "nisi deserunt", + "nisi deserunt" + ] } } ``` @@ -627,7 +635,7 @@ export interface MatchmakingQueueRequest { data: MatchmakingQueueRequestData; } export interface MatchmakingQueueRequestData { - queue: string; + queues: [string, ...string[]]; } ``` ### Response diff --git a/schema/compiled.json b/schema/compiled.json index a21d066..fecf07d 100644 --- a/schema/compiled.json +++ b/schema/compiled.json @@ -1521,8 +1521,14 @@ "data": { "title": "MatchmakingQueueRequestData", "type": "object", - "properties": { "queue": { "type": "string" } }, - "required": ["queue"] + "properties": { + "queues": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1 + } + }, + "required": ["queues"] } }, "required": ["type", "messageId", "commandId", "data"] diff --git a/schema/matchmaking/queue/request.json b/schema/matchmaking/queue/request.json index cbdcc15..fcf777d 100644 --- a/schema/matchmaking/queue/request.json +++ b/schema/matchmaking/queue/request.json @@ -15,8 +15,14 @@ "data": { "title": "MatchmakingQueueRequestData", "type": "object", - "properties": { "queue": { "type": "string" } }, - "required": ["queue"] + "properties": { + "queues": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1 + } + }, + "required": ["queues"] } }, "required": ["type", "messageId", "commandId", "data"] diff --git a/src/schema/matchmaking/README.md b/src/schema/matchmaking/README.md index daaa33b..3e5e4e8 100644 --- a/src/schema/matchmaking/README.md +++ b/src/schema/matchmaking/README.md @@ -1,11 +1,11 @@ The matchmaking cycle works as follows: 1. Clients should first retrieve a list of all the available queues from the server using [list](#list). -2. Clients should then queue for one or more of these queues by sending the queue id in several [queue](#queue) requests. +2. Clients should then queue for one or more of these queues by sending an array of the queue ids in a [queue](#queue) request. 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. 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. \ No newline at end of file diff --git a/src/schema/matchmaking/queue.ts b/src/schema/matchmaking/queue.ts index ceeb281..b5defa6 100644 --- a/src/schema/matchmaking/queue.ts +++ b/src/schema/matchmaking/queue.ts @@ -5,10 +5,10 @@ import { defineEndpoint } from "@/generator-helpers.js"; export default defineEndpoint({ source: "user", target: "server", - description: "Queue up for matchmaking on the specific queue id.", + description: "Queue up for matchmaking. Should cancel the previous queue if already in one.", request: { data: Type.Object({ - queue: Type.String(), + queues: Type.Array(Type.String(), { minItems: 1 }), }), }, response: [ diff --git a/test/cjs/validator.test.cts b/test/cjs/validator.test.cts index 542d13d..d24597d 100644 --- a/test/cjs/validator.test.cts +++ b/test/cjs/validator.test.cts @@ -15,7 +15,7 @@ describe("request", () => { commandId: "matchmaking/queue", messageId: "123", data: { - queue: "1v1", + queues: ["1v1"], }, }; @@ -24,7 +24,7 @@ describe("request", () => { assert.equal(isValid, true); if (isValid) { - assert.equal(command.data.queue, "1v1"); + assert.equal(command.data.queues[0], "1v1"); } }); @@ -35,7 +35,7 @@ describe("request", () => { messageId: "123", data: { // @ts-expect-error - queue: 123, + queues: [], }, }; diff --git a/test/esm/validator.test.mts b/test/esm/validator.test.mts index 26aea96..671f1f7 100644 --- a/test/esm/validator.test.mts +++ b/test/esm/validator.test.mts @@ -15,7 +15,7 @@ describe("request", () => { commandId: "matchmaking/queue", messageId: "123", data: { - queue: "1v1", + queues: ["1v1"], }, }; @@ -24,7 +24,7 @@ describe("request", () => { assert.equal(isValid, true); if (isValid) { - assert.equal(command.data.queue, "1v1"); + assert.equal(command.data.queues[0], "1v1"); } });