Add code to handle the join lobby response

This commit is contained in:
Oliver Akins 2022-03-13 18:31:58 -06:00
parent be3a1c97c9
commit 2c4c7c38b0
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -17,7 +17,16 @@ function handleLobbyCreation(data: ILobbyInfo) {
console.error(data.message); console.error(data.message);
}; };
}; };
function handleLobbyJoin(data: ILobbyInfo) {}; function handleLobbyJoin(data: ILobbyInfo) {
if (data.status == Status.Success) {
console.log(`Succesfully joined lobby`);
gameCode.set(data.game_code);
players.set(data.players);
state.set(`multiplayer-lobby`);
} else {
console.error(data.message);
};
};
onMount(() => { onMount(() => {
socket.on(`res:lobby.create`, handleLobbyCreation); socket.on(`res:lobby.create`, handleLobbyCreation);