protected internal void RemoveConection(string id) { ClientObj 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("Server starts. Waiting for connect..."); while (true) { TcpClient tcpClient = tcpListener.AcceptTcpClient(); ClientObj clientObj = new ClientObj(tcpClient, this); Thread clientThread = new Thread(new ThreadStart(clientObj.Process)); clientThread.Start(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Disconnect(); } }
protected internal void AddConnection(ClientObj clientObj) { clients.Add(clientObj); }