using System; using System.Net; using System.Net.Sockets; using IMDrawLibrary; namespace IMDrawServer { public class Client { string strName; TcpClient tcpClient; public Client() { } public string Name { get { return strName; } set { this.strName = value; } } public TcpClient Socket { get { return tcpClient; } set { this.tcpClient = value; } } public void SendMessage(Message sendMessage) { NetworkStream stream = tcpClient.GetStream(); stream.Write(sendMessage.GetRawMessage(), 0, sendMessage.GetRawMessage().Length); } } public class ClientCollection : System.Collections.CollectionBase { public ClientCollection() { } public Client this[int index] { get { return (Client)List[index]; } set { List[index] = (Client)value; } } public void Add(Client client) { List.Add(client); } public void Remove(string clientName) { for (int i = 0; i < List.Count; i++) { if (((Client)List[i]).Name.Equals(clientName)) { List.Remove(List[i]); } } } public bool Contains(string name) { for (int i = 0; i < List.Count; i++) { if (((Client)List[i]).Name.Equals(name)) { return true; } } return false; } } }