public void DeleteClient(ClientHandlerSocket client) { lock (this) { for (int i = m_aClients.Count - 1; i >= 0; i--) { if (m_aClients[i] == client) { m_aClients.RemoveAt(i); } } } }
protected virtual void Socket_ClientDisconnected(ClientHandlerSocket socket) { Console.WriteLine("Client disconnected."); // Find the player (if only spectator, do nothing) var disconnectedPlayer = PlayersInGame.FirstOrDefault(k => k.Value == socket); if (disconnectedPlayer.Value == null) { return; } // Disconnect the player PlayersInGame.Remove(disconnectedPlayer.Key); PlayerDisconnected.Invoke(disconnectedPlayer.Key); // Check if the game is still running and pause the game if (CurrentState == ServerState.IN_GAME) { PauseGame(); Restart(); } }
private void Server_PlayerConnected(PlayerColor color, string name, ClientHandlerSocket handlerSocket) { Invoke(new Action(() => DisplayPlayerConnected(color, name))); }
protected virtual void Socket_ClientConnected(ClientHandlerSocket socket) { Console.WriteLine("Client connected."); }