Repository navigation
fix: retirer rapidement un joueur qui ferme l'onglet dans le lobby - #18
Merged
Merged
Conversation
Le front envoie "leaving" au pagehide : le serveur retire alors le joueur (et transfère l'hôte) après 5 s au lieu de 5 min. Un F5 se reconnecte à temps. Dans le lobby, l'ancien hôte déconnecté est aussi retiré après le transfert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HSXTbL3JSsPXwTrdrWZXDk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problème
Dans le lobby, un joueur qui fermait son onglet restait affiché et gardait le rôle d'hôte pendant 5 minutes, la durée du délai de grâce prévu pour les reconnexions mobiles.
Solution
frontend/src/context/GameContext.tsx) : aupagehide, sauf si la page part dans le bfcache (event.persisted), la socket envoieleaving.backend/servor.ts) :leavingposesocket.data.leaving. Le gestionnairedisconnectutilise alorsLEAVING_GRACE_PERIOD(5 s, réglable avecLEAVING_GRACE_MS) au lieu deGRACE_PERIOD(5 min).idavant la fin du délai : le joueur garde sa place et son rôle d'hôte.leavinget garde le délai de 5 minutes.host_transferred.Tests
backend/tests/leaving.test.mjs(7 vérifications) : fermeture d'onglet d'un joueur, puis de l'hôte (transfert), F5 de l'hôte, et simple déconnexion qui garde le délai long.SKIP_NETWORK=1 npm test: 14 fichiers OK. Type-check du backend et du frontend OK, eslint OK.Generated by Claude Code