WebSocketServer.CardServer.RemoveClient C# (CSharp) Method

RemoveClient() public method

Removes the specified client from the game, usually due to a disconnect. This also cleans up their votes and other game data.
public RemoveClient ( Client c ) : void
c Client The client to remove.
return void
        public void RemoveClient(Client c)
        {
            // Remove this client's votes if they have any.
            if (ActiveRound != null)
            {
                ActiveRound.Votes.RemoveAll(v => v.ClientID == c.Info.ID && v.ClientName == c.Info.Name);
            }

            if (Admins.Contains(c))
            {
                Admins.Remove(c);
            }
            // Some race case is going on here... we need to check if there's even anything to remove.
            if (Clients.Count > 0)
            {
                Clients.Remove(c);
            }

            c = null;

            if (Clients.All(cl => cl.Info.IsSpectator) && ActiveRound != null)
            {
                DiscardActiveRound();
                BroadcastError(c, "RoundStopped", "There are no more non-spectator players, so the current round has been automatically discarded.");
            }

            // Check that every person hasn't already voted.
            CheckVoteCount();
        }