Bloquear la pantalla del celular expulsa al jugador: los pings no cuentan como actividad - #95
Conversation
…antalla expulse al jugador (Bitcoindefi#17)
|
|
||
| function trackClientActivity(ws: RuntimeClient, packageID: number) { | ||
| const now = Date.now(); | ||
| ws.lastActivityAt = now; |
There was a problem hiding this comment.
⚠️ Edge Case: Ping keepalive now defeats AFK idle-disconnect entirely
The frontend sends a ping every 10s via setInterval(sendPing, 10000) as an automatic keepalive, independent of any user action. By moving ws.lastActivityAt = now before the ping early-return, every connected client with a live socket refreshes lastActivityAt every 10s, so processIdleCharactersTick's idleCharacterTimeoutMs check (server/src/server.ts:735) can never fire for a normally connected client. This fixes the locked-screen case but also disables the general AFK slot-reclamation the idle timeout was built for: only clients that fully stop sending packets get cleaned. If freeing slots from truly-idle-but-connected players is still desired, gate idle detection on gameplay activity (e.g. movement/combat timestamps as getScoutIdleReferenceAt already does) rather than raw connection liveness.
Was this helpful? React with 👍 / 👎
| ws.lastPacketAt = now; | ||
| ws.lastActivityAt = now; | ||
| // ws.lastActivityAt = now; // moved up - now updated for ping packets too |
There was a problem hiding this comment.
💡 Quality: Remove leftover commented-out lastActivityAt assignment
Line 422 leaves a dead commented-out // ws.lastActivityAt = now; // moved up ... in place of the removed assignment. This is clutter that describes the diff rather than the code; delete the comment since the reasoning belongs in the commit message, not the source.
Drop the leftover commented line.:
ws.lastPacketAt = now;
}
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
Closes #17
Problema
trackClientActivityretorna antes de actualizarlastActivityAtcuando el paquete es un ping. El barrido de inactividad usalastActivityAtpara decidir a quién expulsar. Como los pings no lo actualizan, un jugador que solo manda pings (pantalla bloqueada, otra app) es tratado como inactivo y desconectado a los 15 minutos.Solución
Mover
ws.lastActivityAt = nowantes del early-return del ping. Así los pings mantienen viva la conexión sin necesidad de cambiar la lógica de rate limiting.Criterios de aceptación