From 3b5e6432322e2e082d5dfa05f4a973e01a0bf9bc Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Wed, 5 Jan 2022 23:06:22 -0700 Subject: [PATCH] Add docs and types for the game.join event --- common/src/index.ts | 1 + common/src/types/events/game_join.ts | 13 +++++++++++++ docs/events.md | 18 +++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 common/src/types/events/game_join.ts diff --git a/common/src/index.ts b/common/src/index.ts index 42360fe..24fc633 100644 --- a/common/src/index.ts +++ b/common/src/index.ts @@ -9,5 +9,6 @@ export * from "./types/PlayerData"; // Server-Client Communications export * from "./types/ServerResponse"; export * from "./types/events/SaveShip"; +export * from "./types/events/game_join"; export * from "./types/events/server_info"; export * from "./types/events/game_create"; \ No newline at end of file diff --git a/common/src/types/events/game_join.ts b/common/src/types/events/game_join.ts new file mode 100644 index 0000000..6a5039c --- /dev/null +++ b/common/src/types/events/game_join.ts @@ -0,0 +1,13 @@ +import { ServerResponse } from "../ServerResponse"; +import { PlayerData } from "../PlayerData"; + +/** The data required by the server to be able to join a game */ +export interface IGameJoinRequest { + id: string; + name: string; +} + +/** The response that the player receives upon succesfully joining a game. */ +export interface IGameJoinResponse extends ServerResponse { + players?: PlayerData[]; +} \ No newline at end of file diff --git a/docs/events.md b/docs/events.md index f9653e7..91373f7 100644 --- a/docs/events.md +++ b/docs/events.md @@ -39,4 +39,20 @@ Creates a new game lobby for players to be able to join. ### Payload Types: Request Payload: `IGameCreateRequest` -Response Payload: `IGameCreateResponse` \ No newline at end of file +Response Payload: `IGameCreateResponse` + +--- + +## `game.join` +Joins the user into a game, the game must be in the lobby in order to join into +it. + +### Supported Event Types +| Request | Response | Broadcasted +| ------- | -------- | ----------- +| Yes | Yes | No + +### Payloads +Request Payload: `IGameJoinRequest` + +Response Payload: `IGameJoinResponse` \ No newline at end of file