Change response emission to not include "Response"
This commit is contained in:
parent
5d328da49c
commit
79fae1a8a7
2 changed files with 5 additions and 5 deletions
|
|
@ -2,7 +2,7 @@
|
|||
Get's the current player list for a game.
|
||||
|
||||
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 { Game } from '../utils/Game';
|
||||
|
|
@ -11,7 +11,7 @@ import { active_games } from '../main';
|
|||
export const GetPlayerList = (io: Server, socket: Socket, data: GetPlayerList) => {
|
||||
try {
|
||||
if (!Object.keys(active_games).includes(data.game_code)) {
|
||||
socket.emit(`PlayerListResponse`, {
|
||||
socket.emit(`PlayerList`, {
|
||||
success: false,
|
||||
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];
|
||||
|
||||
// Respond to client
|
||||
socket.emit(`PlayerListResponse`, {
|
||||
socket.emit(`PlayerList`, {
|
||||
success: true,
|
||||
players: Object.keys(game.players),
|
||||
});
|
||||
};
|
||||
} catch (err) {
|
||||
// Let client know an error occured
|
||||
socket.emit(`PlayerListResponse`, {
|
||||
socket.emit(`PlayerList`, {
|
||||
success: false,
|
||||
message: `${err.name}: ${err.message}`,
|
||||
})
|
||||
|
|
|
|||
2
src/types/client_data.d.ts
vendored
2
src/types/client_data.d.ts
vendored
|
|
@ -20,7 +20,7 @@ interface GameJoined extends response {
|
|||
players?: string[];
|
||||
}
|
||||
|
||||
interface PlayerListResponse extends response {
|
||||
interface PlayerList extends response {
|
||||
// properties depend on `success` being `true`
|
||||
players?: string[]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue