Handle disconnects, add restart flow and UI fixes

Server: Make DisconnectedPlayer async, await hub notifications, add logging, and delay scheduled deletion (2s). Harden ScheduleGameDeletion with try/catch and only destroy/send GameDestroyed when game is not running or has no players.

Client: Add restart-game flow — expose restartGame on OnlineGame, propagate event from GameEndedMenu (adds local restarted state and disables button), and hook restart handling + player disconnect on unmount in OnlineMode. Also conditionally show bot switch in GameCreationMenu and include replayGameCode in GameEnded interface. Remove automatic reconnect on SignalR connection.

Overall: Improves robustness around player disconnects and adds a UI/logic path for restarting games.
This commit is contained in:
Jonas
2026-03-12 23:18:58 +01:00
parent 0e4fb5d828
commit 7a073b6fff
6 changed files with 61 additions and 18 deletions
+11 -1
View File
@@ -9,7 +9,7 @@ import type { GameSettings } from '@/scripts/interfaces/GameSettings';
import type JoinGameObject from '@/scripts/interfaces/JoinGameObject';
import OnlineGame from '@/scripts/logic/onlineMode/OnlineGame';
import type { GameEnded } from '@/scripts/logic/signalR/GameConnection';
import { ref } from 'vue';
import { onUnmounted, ref } from 'vue';
enum CurrentState {
CreateOrJoinSelection,
@@ -63,6 +63,15 @@ async function createGame() {
async function tryToJoin() {
await game.value.joinGame(joiningModel.value);
}
async function restartGame() {
if(!gameEndedInformation.value?.replayGameCode) return;
await game.value.restartGame(gameEndedInformation.value.replayGameCode);
}
onUnmounted(async () => {
await game.value.player.disconnect();
});
</script>
<template>
@@ -89,6 +98,7 @@ async function tryToJoin() {
<GameEndedMenu
:game-ended-information="gameEndedInformation"
v-else-if="currentState === CurrentState.EndScreen"
@restart-game="restartGame()"
></GameEndedMenu>
<div id="game" v-else>