Ejemplo n.º 1
0
        protected internal void RemoveConnection(string id)
        {
            ClientCore client = clients.FirstOrDefault(c => c.Id == id);

            if (client != null)
            {
                clients.Remove(client);
            }
        }
Ejemplo n.º 2
0
        protected internal void Listen()
        {
            try
            {
                tcpListener = new TcpListener(IPAddress.Any, 8888);
                tcpListener.Start();
                Console.WriteLine("Сервер запущен. Ожидание подключений.");

                while (true)
                {
                    TcpClient tcpClient = tcpListener.AcceptTcpClient();

                    ClientCore clientObject = new ClientCore(tcpClient, this);
                    Thread     clientThread = new Thread(new ThreadStart(clientObject.Process));
                    clientThread.Start();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Disconnect();
            }
        }
Ejemplo n.º 3
0
 protected internal void AddConnection(ClientCore clientObject)
 {
     clients.Add(clientObject);
 }