/// <summary> /// Add a client to the list. /// </summary> /// <param name="client">The client to add</param> public void AddClient(ClientInfo client) { lock (this) { if (!clientList.ContainsKey(client)) { clientList.Add(client.TcpSocketClientHandler, client); Trace.WriteLine(string.Format("{0} added to the server", client)); } } }
/// <summary> /// Remove a client from the list. /// </summary> /// <param name="client">The client to remove</param> public void RemoveClient(ClientInfo client) { if (client == null) { return; } lock (this) { if (clientList.ContainsKey(client.TcpSocketClientHandler)) { clientList.Remove(client.TcpSocketClientHandler); Trace.WriteLine(string.Format("{0} removed from the server", client)); } } }
/// <summary> /// Return a clone of the client list. /// </summary> /// <returns>A clone of the client list as a Client Info array</returns> public ClientInfo[] CloneClientList() { lock (this) { ClientInfo[] handlerList = new ClientInfo[clientList.Count]; clientList.Values.CopyTo(handlerList, 0); return handlerList; } }