feat: add periodic game.status broadcast and live status REST endpoint
Add 20-second game.status WebSocket heartbeat from active shard monitors containing full game state, and GET /status-live REST endpoint for on-demand polling. Fix missing token destructuring in SessionInfo causing crash. Relax frontend polling from 3s to 60s since WebSocket events now cover real-time updates. Bump version to 0.6.0. Made-with: Cursor
This commit is contained in:
@@ -124,13 +124,13 @@ function Picker() {
|
||||
loadData();
|
||||
}, [isAuthenticated, authLoading, navigate, loadData]);
|
||||
|
||||
// Poll for active session status changes
|
||||
// Fallback poll for session status — WebSocket events handle most updates
|
||||
useEffect(() => {
|
||||
if (!isAuthenticated || authLoading) return;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
checkActiveSession();
|
||||
}, 3000);
|
||||
}, 60000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [isAuthenticated, authLoading, checkActiveSession]);
|
||||
@@ -939,7 +939,7 @@ function Picker() {
|
||||
}
|
||||
|
||||
function SessionInfo({ sessionId, onGamesUpdate, playingGame, setPlayingGame }) {
|
||||
const { isAuthenticated } = useAuth();
|
||||
const { isAuthenticated, token } = useAuth();
|
||||
const [games, setGames] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [confirmingRemove, setConfirmingRemove] = useState(null);
|
||||
@@ -968,11 +968,11 @@ function SessionInfo({ sessionId, onGamesUpdate, playingGame, setPlayingGame })
|
||||
loadGames();
|
||||
}, [sessionId, onGamesUpdate, loadGames]);
|
||||
|
||||
// Auto-refresh games list every 3 seconds
|
||||
// Fallback polling — WebSocket events handle most updates; this is a safety net
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
loadGames();
|
||||
}, 3000);
|
||||
}, 60000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [loadGames]);
|
||||
@@ -1011,6 +1011,7 @@ function SessionInfo({ sessionId, onGamesUpdate, playingGame, setPlayingGame })
|
||||
'room.disconnected',
|
||||
'player-count.updated',
|
||||
'game.added',
|
||||
'game.status',
|
||||
];
|
||||
|
||||
if (reloadEvents.includes(message.type)) {
|
||||
|
||||
Reference in New Issue
Block a user