feat(pong): detect when the client hasnt sent anything in X secs
This commit is contained in:
parent
613bb31100
commit
8eac0a0d4e
5 changed files with 61 additions and 13 deletions
|
|
@ -194,15 +194,15 @@ function pongClient(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
|
|||
showError("couldn't find your id in game");
|
||||
}); // TODO: notif user of new game w "ready up" btn
|
||||
|
||||
socket.on("gameEnd", () => {
|
||||
socket.on("gameEnd", (winner) => {
|
||||
queueBtn.innerHTML = QueueState.Iddle;
|
||||
queueBtn.style.color = 'white';
|
||||
|
||||
if (!isNullish(currentGame)) {
|
||||
let new_div = document.createElement('div');
|
||||
let end_txt = "";
|
||||
if ((user.id === currentGame.left.id && currentGame.left.score > currentGame.right.score) ||
|
||||
(user.id === currentGame.right.id && currentGame.right.score > currentGame.left.score))
|
||||
if ((user.id === currentGame.left.id && winner === 'left') ||
|
||||
(user.id === currentGame.right.id && winner === 'right'))
|
||||
end_txt = 'won! #yippe';
|
||||
else
|
||||
end_txt = 'lost #sadge';
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export interface ServerToClient {
|
|||
updateInformation: (info: UpdateInfo) => void,
|
||||
newGame: (initState: GameUpdate) => void, // <- consider this the gameProc eg not start of game but wait for client to "ready up"
|
||||
gameUpdate: (state: GameUpdate) => void,
|
||||
gameEnd: () => void;
|
||||
gameEnd: (winner: 'left' | 'right') => void;
|
||||
};
|
||||
|
||||
export type SSocket = Socket<ClientToServer, ServerToClient>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue