public void RemoveConnection(string id) { ClientObj client = clients.FirstOrDefault(c => c.Id == id); if (client != null) { clients.Remove(client); } }
public void Listen() { try { tcpListener = new TcpListener(IPAddress.Any, 8888); tcpListener.Start(); Console.WriteLine("Сервер запущен. Ожидание подключений..."); while (true) { TcpClient tcpClient = tcpListener.AcceptTcpClient(); ClientObj clientObject = new ClientObj(tcpClient, this); Thread clientThread = new Thread(new ThreadStart(clientObject.Process)); clientThread.Start(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Disconnect(); } }
public void AddConnection(ClientObj clientObject) { clients.Add(clientObject); }