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