Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e76d0b0f07 | ||
|
|
b7693bd9d0 |
+1
-1
@@ -23,7 +23,7 @@ MYSQL_ROOT_PASSWORD=CHANGEME_MYSQL_ROOT_PASSWORD
|
|||||||
MERCURE_URL=http://mercure/.well-known/mercure
|
MERCURE_URL=http://mercure/.well-known/mercure
|
||||||
MERCURE_PUBLIC_URL=https://mercure.escapepage.com/.well-known/mercure
|
MERCURE_PUBLIC_URL=https://mercure.escapepage.com/.well-known/mercure
|
||||||
MERCURE_JWT_SECRET=CHANGEME_MERCURE_JWT_SECRET
|
MERCURE_JWT_SECRET=CHANGEME_MERCURE_JWT_SECRET
|
||||||
MERCURE_CORS_ALLOWED_ORIGINS="https://www.escapepage.com https://escapepage.com"
|
MERCURE_CORS_ALLOWED_ORIGINS=https://www.escapepage.com https://escapepage.com
|
||||||
MERCURE_TOPIC_BASE=https://escapepage.com
|
MERCURE_TOPIC_BASE=https://escapepage.com
|
||||||
|
|
||||||
# Recaptcha
|
# Recaptcha
|
||||||
|
|||||||
@@ -326,12 +326,17 @@ final class GameDashboardService
|
|||||||
$this->checkAllPlayersReady($session);
|
$this->checkAllPlayersReady($session);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
// If this toggle just made everyone ready, checkAllPlayersReady() already
|
||||||
|
// transitioned the session out of READY and published 'all_ready' —
|
||||||
|
// don't also publish a redundant 'player_ready'.
|
||||||
|
if ($session->getStatus() === SessionStatus::READY) {
|
||||||
try {
|
try {
|
||||||
$topic = '/game/hub/' . $session->getId();
|
$topic = '/game/hub/' . $session->getId();
|
||||||
$this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready', 'player' => $player->getScreen(), 'ready' => !$setting])));
|
$this->hub->publish(new Update($topic, json_encode(['type' => 'player_ready', 'player' => $player->getScreen(), 'ready' => !$setting])));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Mercure might be down, but we don't want to crash the game
|
// Mercure might be down, but we don't want to crash the game
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,18 @@
|
|||||||
const topic = config.dataset.topic;
|
const topic = config.dataset.topic;
|
||||||
const readyAt = config.dataset.readyAt;
|
const readyAt = config.dataset.readyAt;
|
||||||
|
|
||||||
|
let reloading = false;
|
||||||
|
const reloadOnce = (eventSource) => {
|
||||||
|
if (reloading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reloading = true;
|
||||||
|
if (eventSource) {
|
||||||
|
eventSource.close();
|
||||||
|
}
|
||||||
|
window.location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
if (publicUrl && topic) {
|
if (publicUrl && topic) {
|
||||||
const url = new URL(publicUrl);
|
const url = new URL(publicUrl);
|
||||||
url.searchParams.append('topic', topic);
|
url.searchParams.append('topic', topic);
|
||||||
@@ -99,7 +111,7 @@
|
|||||||
eventSource.onmessage = event => {
|
eventSource.onmessage = event => {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
if (data.type === 'all_ready' || data.type === 'player_ready') {
|
if (data.type === 'all_ready' || data.type === 'player_ready') {
|
||||||
window.location.reload();
|
reloadOnce(eventSource);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -113,12 +125,10 @@
|
|||||||
const timeLeft = timeoutMs - timeElapsed;
|
const timeLeft = timeoutMs - timeElapsed;
|
||||||
|
|
||||||
if (timeLeft > 0) {
|
if (timeLeft > 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => reloadOnce(), timeLeft);
|
||||||
window.location.reload();
|
|
||||||
}, timeLeft);
|
|
||||||
} else {
|
} else {
|
||||||
// Already timed out, reload to sync with server
|
// Already timed out, reload to sync with server
|
||||||
window.location.reload();
|
reloadOnce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user