From 1380a7919b3b1311e440deb5f3ba009d2297122f Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Wed, 30 Sep 2020 23:49:10 -0600 Subject: [PATCH] Update/add file headers for documentation purposes --- src/events/GetPlayerList.ts | 3 +++ src/events/HostGame.ts | 5 +++-- src/events/JoinGame.ts | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/events/GetPlayerList.ts b/src/events/GetPlayerList.ts index 94f3b99..2ee3ea4 100644 --- a/src/events/GetPlayerList.ts +++ b/src/events/GetPlayerList.ts @@ -1,6 +1,9 @@ /* Get's the current player list. This is only really used by the host. This is almost never called by the client itself + +Emissions: + PlayerListResponse->sender - Sends the list of players to the client */ import * as db from '../utils/db'; import { Socket } from 'socket.io'; diff --git a/src/events/HostGame.ts b/src/events/HostGame.ts index f4659c9..927e983 100644 --- a/src/events/HostGame.ts +++ b/src/events/HostGame.ts @@ -3,8 +3,9 @@ Starts a game on the server, this also acts as the `JoinGame` event for the host, except that it doesn't send any events out to other players as there are none yet. -This will also emit the `HostInformation` event to the host client, which will -allow us to send them information about what the game code is +Emissions: + HostInformation - Data containing if the game created successfully or not + and the game code for the game if it was successful. Client Side: After the host receives the `HostInformation` event, the Query String parameters should be updated with the Websocket URI and the game code so diff --git a/src/events/JoinGame.ts b/src/events/JoinGame.ts index 9e82d0e..2d9fda5 100644 --- a/src/events/JoinGame.ts +++ b/src/events/JoinGame.ts @@ -1,3 +1,13 @@ +/* +Connects to an already existing game on the server. + +Emissions: + NewPlayer->A!sender - This event is sent to other players who are in + the lobby to allow them to update their view so that they see all the + players in the lobby at all times. + GameJoined->sender - Sent to the client to tell them the current list of + players and that they were added to the game either successfully or not +*/ import { Socket } from 'socket.io'; export const JoinGame = (socket: Socket, data: JoinGame) => { console.log(`User: ${data.username} (${data.game_code})`);