feat: add connection status indicator with SSE heartbeat
- Add ConnectionIndicator component showing green/red dot - Send lastPing signal every 15 seconds via SSE - Indicator turns red if no ping received in 20 seconds - Gives users confidence the live connection is active
This commit is contained in:
@@ -44,6 +44,21 @@ templ NicknamePrompt(returnPath string) {
|
||||
</main>
|
||||
}
|
||||
|
||||
// ConnectionIndicator shows a small dot indicating SSE connection status.
|
||||
// It requires a `lastPing` signal (unix ms timestamp) to be set by the server.
|
||||
templ ConnectionIndicator() {
|
||||
<div
|
||||
id="connection-indicator"
|
||||
class="fixed top-2 right-2 flex items-center gap-1 text-xs text-gray-500"
|
||||
title="Connection status"
|
||||
>
|
||||
<span
|
||||
class="w-2 h-2 rounded-full transition-colors duration-300"
|
||||
data-class="{'bg-green-500': Date.now() - $lastPing < 20000, 'bg-red-500': Date.now() - $lastPing >= 20000}"
|
||||
></span>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ GameJoinPrompt(loginURL string, registerURL string, gamePath string) {
|
||||
<main class="max-w-sm mx-auto mt-8 text-center">
|
||||
<h1 class="text-3xl font-bold">Join Game</h1>
|
||||
|
||||
Reference in New Issue
Block a user