Example #1
0
        /// <summary>
        /// Waits tcp-client to work with him/her (bot).
        /// </summary>
        protected internal void Listen()
        {
            try
            {
                tcpListener = new TcpListener(IPAddress.Any, 8888);
                tcpListener.Start();
                Console.WriteLine("The server is waiting for client response...");

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

                    ClientView clientView = new ClientView(tcpClient, this);
                    Task       task       = new Task(clientView.Process);
                    task.Start();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Disconnect();
            }
        }
Example #2
0
        /// <summary>
        /// Adds a new client.
        /// </summary>
        /// <param name="clientView">A new client.</param>
        protected internal void AddConnection(ClientView clientView)
        {
            clients.Add(clientView);

            Console.WriteLine($"Number of connected clients: {clients.Count}");
        }