feat: tick live clock every second via SSE heartbeat
All checks were successful
CI / Deploy / test (pull_request) Successful in 14s
CI / Deploy / lint (pull_request) Successful in 25s
CI / Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
Ryan Hamamura
2026-03-03 13:28:59 -10:00
parent 9a8fe4534d
commit c826981b4d
4 changed files with 2613 additions and 4 deletions

View File

@@ -97,7 +97,7 @@ func HandleGameEvents(store *connect4.Store, svc *services.GameService, sm *scs.
defer cleanupChat()
// Setup heartbeat BEFORE creating SSE
heartbeat := time.NewTicker(10 * time.Second)
heartbeat := time.NewTicker(1 * time.Second)
defer heartbeat.Stop()
// NOW create SSE

View File

@@ -48,7 +48,7 @@ templ NicknamePrompt(returnPath string) {
</main>
}
// LiveClock shows the current server time, updated with each SSE patch.
// LiveClock shows the current server time, updated every second via SSE.
// If the clock stops updating, users know the connection is stale.
templ LiveClock() {
<div class="fixed top-2 right-2 flex items-center gap-1.5 text-xs opacity-60 font-mono">

View File

@@ -122,7 +122,7 @@ func HandleSnakeEvents(snakeStore *snake.SnakeStore, svc *services.GameService,
return
}
heartbeat := time.NewTicker(10 * time.Second)
heartbeat := time.NewTicker(1 * time.Second)
defer heartbeat.Stop()
// Chat subscription (multiplayer only)