Exemplo n.º 1
0
        protected internal void Listen()
        {
            try
            {
                _tcpListener = new TcpListener(IPAddress.Any, ExitPort);
                _tcpListener.Start();
                Task.Run(Sender);
                Started?.Invoke();

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

                    var ip = ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString();
                    if (!_permittedIp.Contains(ip))
                    {
                        tcpClient.Close();
                        continue;
                    }

                    AdminPanelClient clientObject = new AdminPanelClient(tcpClient, this);
                    clientObject.Token = PermittedToken;

                    Thread clientThread = new Thread(clientObject.Process);
                    clientThread.Start();
                }
            }
            catch (Exception ex)
            {
                Disconnect();
                Disconnected?.Invoke();
            }
        }
Exemplo n.º 2
0
        protected internal void RemoveConnection(string id)
        {
            AdminPanelClient client = _clients.FirstOrDefault(c => c.Id == id);

            if (client != null)
            {
                _clients.Remove(client);
            }
        }
Exemplo n.º 3
0
 protected internal void AddConnection(AdminPanelClient clientObject)
 {
     _clients.Add(clientObject);
 }