Exemplo n.º 1
0
        protected internal void RemoveConection(string id)
        {
            ClientObj client = clients.FirstOrDefault(c => c.id == id);

            if (client != null)
            {
                clients.Remove(client);
            }
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
 protected internal void AddConnection(ClientObj clientObj)
 {
     clients.Add(clientObj);
 }