Example #1
0
        public void RemoveConnection(string id)
        {
            ClientObj client = clients.FirstOrDefault(c => c.Id == id);

            if (client != null)
            {
                clients.Remove(client);
            }
        }
Example #2
0
        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();
            }
        }
Example #3
0
 public void AddConnection(ClientObj clientObject)
 {
     clients.Add(clientObject);
 }