Implementar controles globales de admin en dashboard

- Agregados botones de control global: pausar, reanudar, reiniciar, cambiar variante, enviar al lobby
- Implementados endpoints API para operaciones masivas en todas las game rooms
- Agregado método executeAdminCommand en GameRoom para manejo unificado de comandos admin
- Mejorado manejo de desconexión automática al lobby cuando admin cierra rooms
- Interfaz responsiva con confirmaciones de usuario y estados de carga
- Sistema robusto de limpieza de rooms con fallback de forzado
This commit is contained in:
2025-08-12 18:13:53 -06:00
parent b754ec043a
commit e14bdddc62
4 changed files with 568 additions and 16 deletions

View File

@@ -200,9 +200,43 @@ onMounted(() => {
// Game paused, could update UI state if needed
});
room.onMessage("gameRestart", () => {
// Game restarted, could update UI state if needed
});
room.onMessage("variantChanged", (data: { variant: string }) => {
currentVariant.value = data.variant as any;
});
// Handle room closure/disconnection
room.onLeave((code) => {
console.log('[DemoGame] Room disconnected with code:', code);
// Always clean up local storage when room closes
try {
if (typeof window !== 'undefined') {
window.localStorage.removeItem('snatch.game.roomId');
window.localStorage.removeItem('snatch.game.sessionId');
}
} catch {}
// If not on lobby page, redirect there
if (router.currentRoute.value.path !== '/') {
console.log('[DemoGame] Room closed, redirecting to lobby');
router.push('/');
}
});
room.onError((code, message) => {
console.error('[DemoGame] Room error:', code, message);
// On error, also redirect to lobby
try {
if (typeof window !== 'undefined') {
window.localStorage.removeItem('snatch.game.roomId');
window.localStorage.removeItem('snatch.game.sessionId');
}
} catch {}
router.push('/');
});
}
});
@@ -223,6 +257,7 @@ function onReport(val: boolean) { colyseusService.report(val); }
function onAssignShame(val: boolean) { colyseusService.assignShame(val); }
function leaveGame() {
console.log('[DemoGame] User manually leaving game');
colyseusService.leaveGame();
try { if (typeof window !== 'undefined') { window.localStorage.removeItem('snatch.game.roomId'); window.localStorage.removeItem('snatch.game.sessionId'); } } catch {}
router.push('/');