Remove 60-second ready-status expiry so the group can always start
Ready status previously expired 60 seconds after a player checked the box, evaluated per-player against their own timestamp. Unless every player happened to click ready within the same 60-second window, the earliest player's readiness would silently expire before the last one joined, so the session could get stuck on "Waiting for all players to be ready" indefinitely, especially after a reload re-triggered the timeout check. Ready state is now durable: once checked, it stays until the player unchecks it or the whole group is simultaneously ready, at which point the session always transitions to PLAYING regardless of how long that took. session.timer is still only ever set once during that one-way READY -> PLAYING transition, so a reload never restarts or desyncs the countdown between players.
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<p class="text-muted small">
|
||||
Note: If all players are not ready within 1 minute of you checking this, your status will be reset automatically.
|
||||
As soon as everyone has checked this box, the game starts automatically for everyone.
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
<div id="mercure-config"
|
||||
data-mercure-public-url="{{ mercure_public_url|e('html_attr') }}"
|
||||
data-topic="/game/hub/{{ session.id|e('html_attr') }}"
|
||||
data-ready-at="{{ readyAt|e('html_attr') }}"
|
||||
style="display:none">
|
||||
</div>
|
||||
|
||||
@@ -87,7 +86,6 @@
|
||||
const config = document.getElementById('mercure-config');
|
||||
const publicUrl = config.dataset.mercurePublicUrl;
|
||||
const topic = config.dataset.topic;
|
||||
const readyAt = config.dataset.readyAt;
|
||||
|
||||
let reloading = false;
|
||||
const reloadOnce = (eventSource) => {
|
||||
@@ -113,21 +111,5 @@
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Client-side timeout for ready status
|
||||
if (readyAt) {
|
||||
const timeoutMs = 61000; // 61 seconds (slightly more than server-side 60s)
|
||||
const now = Date.now();
|
||||
const readyAtMs = readyAt * 1000;
|
||||
const timeElapsed = now - readyAtMs;
|
||||
const timeLeft = timeoutMs - timeElapsed;
|
||||
|
||||
if (timeLeft > 0) {
|
||||
setTimeout(() => reloadOnce(), timeLeft);
|
||||
} else {
|
||||
// Already timed out, reload to sync with server
|
||||
reloadOnce();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user