Skip to content

fix(session): auto-reconnect WebSocket with backoff and ticket refresh (#18) - #333

Open
Aduersarius wants to merge 1 commit into
Bitcoindefi:mainfrom
Aduersarius:fix/websocket-auto-reconnect-18
Open

fix(session): auto-reconnect WebSocket with backoff and ticket refresh (#18)#333
Aduersarius wants to merge 1 commit into
Bitcoindefi:mainfrom
Aduersarius:fix/websocket-auto-reconnect-18

Conversation

@Aduersarius

Copy link
Copy Markdown

Closes #18

Summary

Adds automatic WebSocket reconnection when the game socket drops, without requiring a full page reload or character re-select.

Approach

  • Hook-level reconnect in useGameSession.ts: exponential backoff (1s → 2s → … capped at 30s, max 6 attempts), no reconnect storm while the server is down.
  • Full handshake on resume: each attempt re-sends connectCharacter and refreshes the game/arena ticket via refreshConnectionCredentials (tickets can expire).
  • Background / network recovery: visibilitychange, pageshow, pagehide, and online trigger a wake reconnect when returning from background or regaining network.
  • Visible connection state on the play page: countdown while scheduled, cancel during reconnect, manual Reconectar when attempts are exhausted or cancelled.
  • Intentional closes (closeForce / logout teardown) do not auto-reconnect.

Files

  • frontend/components/game/session/useGameSession.ts
  • frontend/components/game/core/MapRendererCore.tsx (prop/status wiring only)
  • frontend/app/play/page.tsx (ticket refresh + reconnect UI)

Acceptance

  • Network drop then restore reconnects without full page reload
  • Returning from background reconnects
  • Server down → exponential backoff, no reconnect storm
  • Visible connection state (+ cancel / manual reconnect when exhausted)
  • Same character preserved; full handshake + ticket refresh

Differentiation vs open PRs

Test plan

  • Connect to play, kill network briefly, restore → auto-reconnect + same character
  • Background the tab/app, return → reconnect without reload
  • Stop game server → spaced attempts, then Reconectar after exhausted
  • Cancelar reconexion stops further attempts
  • Arena room path regenerates ticket on reconnect

Bitcoindefi#18)

Reconnect from useGameSession with exponential backoff, visibility/pagehide/online
wakeups, fresh game/arena tickets, and cancel/manual controls on the play page.
@gitar-bot

gitar-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No hay reconexion automatica: si se corta la conexion hay que recargar la pagina

1 participant