private void CheckForGameOver(int fromConnectionId) { if (GameSessionState != GameOverState) { GameSessionState = GameOverState; foreach (KeyValuePair <int, string> playerSession in _playerSessions) { // send out the win/lose status to all players BADNetworkMessage responseMessage; if (playerSession.Key == fromConnectionId) { responseMessage = new BADNetworkMessage("WIN", playerSession.Value); } else { responseMessage = new BADNetworkMessage("LOSE", playerSession.Value); } SendMessage(playerSession.Key, responseMessage); _gameLiftServer.RemovePlayerSession(playerSession.Value); // player session id _server.Disconnect(playerSession.Key); } Debug.Log($"Ending game, player with connection Id {fromConnectionId} hit W first."); _gameLiftServer.HandleGameEnd(); } else { Debug.Log("CheckForGameOver: Game over already being processed."); } }
public override bool ServerDisconnect(int connectionId) => server.Disconnect(connectionId);