feat(pong): detect when the client hasnt sent anything in X secs

This commit is contained in:
Maieul BOYER 2026-01-05 17:43:05 +01:00 committed by Nigel
parent 613bb31100
commit 8eac0a0d4e
5 changed files with 61 additions and 13 deletions

View file

@ -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';