示例#1
0
        protected internal void RemoveConnection(string id)
        {
            ClientTCP client = clients.FirstOrDefault(c => c.Id == id);

            if (client != null)
            {
                clients.Remove(client);
            }
        }
示例#2
0
        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();
            }
        }
示例#3
0
 protected internal void AddConnection(ClientTCP clientTCP)
 {
     clients.Add(clientTCP);
 }