Add game restart and disconnect support
Prevent handling disconnects for games already ended; add a disconnect() method on the SignalR connection and a LocalGame.disconnectAll() helper. Update GameEndedMenu to emit a restart event and adjust displayed messages/labels. Wire a restart() handler in LocalMode that disconnects all players then restarts the game.
This commit is contained in:
@@ -120,7 +120,7 @@ public class GameManager(IGameRepository gameRepository, IHubContext<GameHubSock
|
||||
public Task DisconnectedPlayer(string playerConnectionId)
|
||||
{
|
||||
var game = gameRepository.GetOneByConnectionId(playerConnectionId);
|
||||
if (game == null)
|
||||
if (game == null || game.State == GameState.Ended)
|
||||
return Task.CompletedTask;
|
||||
|
||||
var player = game.GetPlayerByConnectionId(playerConnectionId);
|
||||
|
||||
Reference in New Issue
Block a user