private void OnPlayerLeft(IPlayer player, LeaveReasons reason) { Log.Default.WriteLine(LogLevels.Info, "Player left:{0} {1}", player.Name, reason); bool wasServerMaster = false; // Remove from player manager lock (_playerManager.LockObject) { if (player == _playerManager.ServerMaster) { wasServerMaster = true; } // Remove player from player list _playerManager.Remove(player); } // Clean host tables foreach (IHost host in _hosts) { host.RemovePlayer(player); } // If game was running and player was playing, check if only one player left (see GameLostHandler) if ((State == ServerStates.GameStarted || State == ServerStates.GamePaused) && player.State == PlayerStates.Playing) { int playingCount = _playerManager.Players.Count(p => p.State == PlayerStates.Playing); if (playingCount == 0 || playingCount == 1) { Log.Default.WriteLine(LogLevels.Info, "Game finished by forfeit no winner"); State = ServerStates.GameFinished; GameStatistics statistics = PrepareGameStatistics(); // Send game finished (no winner) foreach (IEntity entity in Entities.Where(x => x != player)) { entity.OnGameFinished(statistics); } State = ServerStates.WaitingStartGame; } } // Inform players and spectators except disconnected player foreach (IEntity entity in Entities.Where(x => x != player)) { entity.OnPlayerLeft(player.Id, player.Name, reason); } // Send new server master id if (wasServerMaster) { IPlayer serverMaster = _playerManager.ServerMaster; if (serverMaster != null) { foreach (IEntity entity in Entities.Where(x => x != player)) { entity.OnServerMasterChanged(serverMaster.Id); } } } }
private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason) { lock (_lock) { Console.ResetColor(); Console.SetCursorPosition(_client.Board.Width + 2 + BoardStartX, 2); Console.Write("{0} [{1}] left {2}", playerName, playerId, reason); } }
private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason) { if (Client.IsSpectator) return; OpponentViewModel opponent = GetOpponentViewModel(playerId); if (opponent != null) { opponent.PlayerId = -1; opponent.PlayerName = "Not playing"; opponent.Team = ""; } }
private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason) { if (!Client.IsSpectator) { return; } OpponentViewModel opponent = OpponentsViewModel[playerId]; if (opponent != null) { opponent.PlayerId = -1; opponent.PlayerName = "Not playing"; opponent.Team = ""; } }
private void OnSpectatorLeft(ISpectator spectator, LeaveReasons reason) { Log.Default.WriteLine(LogLevels.Info, "Spectator left:{0} {1}", spectator.Name, reason); // Remove from spectator lock (_spectatorManager.LockObject) { // Remove spectator from spectator list _spectatorManager.Remove(spectator); } // Clean host tables foreach (IHost host in _hosts) { host.RemoveSpectator(spectator); } // Inform players and spectators except disconnected spectator foreach (IEntity entity in Entities.Where(x => x != spectator)) { entity.OnSpectatorLeft(spectator.Id, spectator.Name, reason); } }
private void OnPlayerLeft(int playerid, string playerName, LeaveReasons reason) { string msg; switch (reason) { case LeaveReasons.Spam: msg = String.Format("*** {0} has been BANNED [SPAM]", playerName); break; case LeaveReasons.Disconnected: msg = String.Format("*** {0} has disconnected", playerName); break; case LeaveReasons.ConnectionLost: msg = String.Format("*** {0} has left [connection lost]", playerName); break; case LeaveReasons.Timeout: msg = String.Format("*** {0} has left [timeout]", playerName); break; case LeaveReasons.Ban: msg = String.Format("*** {0} has been BANNED", playerName); break; case LeaveReasons.Kick: msg = String.Format("*** {0} has been kicked", playerName); break; default: msg = String.Format("*** {0} has left {1}", playerName, reason); break; } AddServerMessage(ChatColor.Green, msg); }
public void OnClientDisconnected(Guid clientId, LeaveReasons reason) { UpdateCallInfo(System.Reflection.MethodBase.GetCurrentMethod().Name, clientId, reason); }
public void OnAdminDisconnected(Guid adminId, LeaveReasons reason) { _admins.RemoveAll(x => x.Id == adminId); AdminDisconnected.Do(x => x(adminId, reason)); }
public void OnAdminDisconnected(Guid adminId, LeaveReasons reason) { UpdateCallInfo(System.Reflection.MethodBase.GetCurrentMethod().Name, adminId, reason); }
private static void OnAdminDisconnected(Guid adminId, LeaveReasons reason) { Console.WriteLine("OnAdminDisconnected: {0} {1}", adminId, reason); DisplayAdminList(); }
public void OnClientDisconnected(Guid clientId, LeaveReasons reason) { _clients.RemoveAll(x => x.Id == clientId); ClientDisconnected.Do(x => x(clientId, reason)); }
public void OnPlayerLeft(int playerId, string name, LeaveReasons reason) { UpdateCallCount(System.Reflection.MethodBase.GetCurrentMethod().Name); }
public void OnClientDisconnected(Guid clientId, LeaveReasons reason) { Log.Default.WriteLine(LogLevels.Info, "Client disconnected {0} {1}", clientId, reason); ResetTimeout(); ClientData clientInGame = _gameClients.FirstOrDefault(x => x.Id == clientId); // If client was in game, remove it if (clientInGame != null) { Log.Default.WriteLine(LogLevels.Info, "Client disconnected {0} and removed from game", clientId); _gameClients.RemoveAll(x => x.Id == clientId); ClientGameLeft.Do(x => x(clientInGame)); } // Remove client ClientData client = _clients.FirstOrDefault(x => x.Id == clientId); if (client != null) _clients.RemoveAll(x => x.Id == clientId); ClientDisconnected.Do(x => x(client, reason)); }
public void OnSpectatorLeft(int spectatorId, string name, LeaveReasons reason) { throw new NotImplementedException(); }
private static void OnClientDisconnected(Guid clientId, LeaveReasons reason) { Console.WriteLine("OnClientDisconnected: {0} {1}", clientId, reason); DisplayClientList(); }
public void OnPlayerLeft(int playerId, string name, LeaveReasons reason) { ExceptionFreeAction(() => Callback.OnPlayerLeft(playerId, name, reason)); }
public void OnPlayerLeft(int playerId, string name, LeaveReasons reason) { Log.Default.WriteLine(LogLevels.Info, "OnPlayedLeft[{0}]:{1}[{2}] {3}", PlayerName, name, playerId, reason); ResetTimeout(); }
public void OnAdminDisconnected(Guid adminId, LeaveReasons reason) { throw new NotImplementedException(); }
private void OnSpectatorLeft(int spectatorId, string spectatorName, LeaveReasons reason) { DeleteSpectatorEntry(spectatorId, spectatorName); }
private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason) { DeletePlayerEntry(playerId, playerName); }
public void OnClientDisconnected(Guid clientId, LeaveReasons reason) { ExceptionFreeAction(() => Callback.OnClientDisconnected(clientId, reason)); }
private void OnClientDisconnected(ClientData client, LeaveReasons reason) { Console.WriteLine("OnClientDisconnected: {0} {1}", client == null ? Guid.Empty : client.Id, reason); DisplayClientList(); }
public void OnSpectatorLeft(int spectatorId, string name, LeaveReasons reason) { ExceptionFreeAction(() => Callback.OnSpectatorLeft(spectatorId, name, reason)); }
private void OnSpectatorLeft(int spectatorId, string spectatorName, LeaveReasons reason) { OnPlayerLeft(spectatorId, spectatorName, reason); }
public void OnSpectatorLeft(int spectatorId, string name, LeaveReasons reason) { Log.Default.WriteLine(LogLevels.Info, "OnSpectatorLeft[{0}]:{1}[{2}] {3}", PlayerName, name, spectatorId, reason); }
public void OnClientDisconnected(Guid clientId, LeaveReasons reason) { throw new NotImplementedException(); }
public void OnPlayerLeft(int playerId, string name, LeaveReasons reason) { throw new NotImplementedException(); }
public void OnAdminDisconnected(Guid adminId, LeaveReasons reason) { ExceptionFreeAction(() => Callback.OnAdminDisconnected(adminId, reason)); }