Change response emission to not include "Response"

This commit is contained in:
Oliver-Akins 2020-10-08 23:05:13 -06:00
parent 5d328da49c
commit 79fae1a8a7
2 changed files with 5 additions and 5 deletions

View file

@ -2,7 +2,7 @@
Get's the current player list for a game. Get's the current player list for a game.
Emissions: Emissions:
PlayerListResponse->sender - Sends the list of players to the client PlayerList->sender - Sends the list of players to the client
*/ */
import { Server, Socket } from 'socket.io'; import { Server, Socket } from 'socket.io';
import { Game } from '../utils/Game'; import { Game } from '../utils/Game';
@ -11,7 +11,7 @@ import { active_games } from '../main';
export const GetPlayerList = (io: Server, socket: Socket, data: GetPlayerList) => { export const GetPlayerList = (io: Server, socket: Socket, data: GetPlayerList) => {
try { try {
if (!Object.keys(active_games).includes(data.game_code)) { if (!Object.keys(active_games).includes(data.game_code)) {
socket.emit(`PlayerListResponse`, { socket.emit(`PlayerList`, {
success: false, success: false,
message: `Error: ${data.game_code} does not have an active game object.`, message: `Error: ${data.game_code} does not have an active game object.`,
}); });
@ -19,14 +19,14 @@ export const GetPlayerList = (io: Server, socket: Socket, data: GetPlayerList) =
let game: Game = active_games[data.game_code]; let game: Game = active_games[data.game_code];
// Respond to client // Respond to client
socket.emit(`PlayerListResponse`, { socket.emit(`PlayerList`, {
success: true, success: true,
players: Object.keys(game.players), players: Object.keys(game.players),
}); });
}; };
} catch (err) { } catch (err) {
// Let client know an error occured // Let client know an error occured
socket.emit(`PlayerListResponse`, { socket.emit(`PlayerList`, {
success: false, success: false,
message: `${err.name}: ${err.message}`, message: `${err.name}: ${err.message}`,
}) })

View file

@ -20,7 +20,7 @@ interface GameJoined extends response {
players?: string[]; players?: string[];
} }
interface PlayerListResponse extends response { interface PlayerList extends response {
// properties depend on `success` being `true` // properties depend on `success` being `true`
players?: string[] players?: string[]
} }