Add code to handle the join lobby response
This commit is contained in:
parent
be3a1c97c9
commit
2c4c7c38b0
1 changed files with 10 additions and 1 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue