Fix SSE architecture for reliable connections #13
File diff suppressed because one or more lines are too long
@@ -97,7 +97,7 @@ func HandleGameEvents(store *connect4.Store, svc *services.GameService, sm *scs.
|
|||||||
defer cleanupChat()
|
defer cleanupChat()
|
||||||
|
|
||||||
// Setup heartbeat BEFORE creating SSE
|
// Setup heartbeat BEFORE creating SSE
|
||||||
heartbeat := time.NewTicker(10 * time.Second)
|
heartbeat := time.NewTicker(1 * time.Second)
|
||||||
defer heartbeat.Stop()
|
defer heartbeat.Stop()
|
||||||
|
|
||||||
// NOW create SSE
|
// NOW create SSE
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ templ NicknamePrompt(returnPath string) {
|
|||||||
</main>
|
</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.
|
// If the clock stops updating, users know the connection is stale.
|
||||||
templ LiveClock() {
|
templ LiveClock() {
|
||||||
<div class="fixed top-2 right-2 flex items-center gap-1.5 text-xs opacity-60 font-mono">
|
<div class="fixed top-2 right-2 flex items-center gap-1.5 text-xs opacity-60 font-mono">
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func HandleSnakeEvents(snakeStore *snake.SnakeStore, svc *services.GameService,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
heartbeat := time.NewTicker(10 * time.Second)
|
heartbeat := time.NewTicker(1 * time.Second)
|
||||||
defer heartbeat.Stop()
|
defer heartbeat.Stop()
|
||||||
|
|
||||||
// Chat subscription (multiplayer only)
|
// Chat subscription (multiplayer only)
|
||||||
|
|||||||
Reference in New Issue
Block a user