Exemple #1
0
        public Client(ClientData clientData, CoreClientInformation computerInformation, TcpClient client,
                      BinaryReader binaryReader, BinaryWriter binaryWriter, SslStream sslStream, ITcpServerInfo tcpServerInfo,
                      LocationInfo locationInfo)
        {
            Id           = clientData.Id;
            LocationInfo = locationInfo;

            var endPoint = (IPEndPoint)client.Client.RemoteEndPoint;

            Ip   = endPoint.Address.ToString();
            Port = endPoint.Port;
            Data = clientData;
            ComputerInformation = computerInformation;
            _client             = client;
            _binaryReader       = binaryReader;
            _binaryWriter       = binaryWriter;
            _sslStream          = sslStream;
            _tcpServerInfo      = tcpServerInfo;

            client.ReceiveTimeout = 0;
            client.SendTimeout    = 0;

            _readByteDelegate += binaryReader.ReadByte;
            OnlineSince        = DateTime.UtcNow;
            LastAnswer         = DateTime.UtcNow;
        }
        public Administration(ushort id, IConnection connection, ITcpServerInfo tcpServerInfo)
        {
            Id         = id;
            Connection = connection;

            _tcpServerInfo = tcpServerInfo;

            connection.SetTimeout(0);

            _openClientSessions = new List <int>();
            _dtpProcessor       = new DtpProcessor(this);
            InitializeDataTransferProtocol();
            tcpServerInfo.DynamicCommandManager.DynamicCommandAdded       += DynamicCommandManagerOnDynamicCommandAdded;
            tcpServerInfo.DynamicCommandManager.DynamicCommandEventsAdded +=
                DynamicCommandManagerOnDynamicCommandEventsAdded;
            tcpServerInfo.DynamicCommandManager.DynamicCommandStatusUpdated +=
                DynamicCommandManagerOnDynamicCommandStatusUpdated;

            var activeCommandEventManagerBrake =
                new ActiveCommandEventManagerBrake(tcpServerInfo.DynamicCommandManager.ActiveCommandEventManager);

            activeCommandEventManagerBrake.PushChanges += ActiveCommandEventManagerBrakeOnPushChanges;

            new Thread(() => Read(connection.BinaryReader))
            {
                Name = $"AI-{id}_ListeningThread", IsBackground = true
            }
            .Start();
        }
        public override List <int> Execute(byte[] parameter, List <TargetedClient> clients, ITcpServerInfo tcpServerInfo)
        {
            var sentList = new List <int>();

            foreach (var targetedClient in clients)
            {
                if (targetedClient.ClientInformation.MacAddressBytes != null)
                {
                    WakeOnLan(targetedClient.ClientInformation.MacAddressBytes);
                    sentList.Add(targetedClient.Id);
                }
            }

            return(sentList);
        }
 /// <summary>
 ///     Execute the special command
 /// </summary>
 /// <param name="parameter">The parameter for the command</param>
 /// <param name="clients">The clients which should execute the command (only online clients)</param>
 /// <param name="tcpServerInfo">Some useful information</param>
 /// <returns>Return the clients which received the command</returns>
 public abstract List <int> Execute(byte[] parameter, List <TargetedClient> clients, ITcpServerInfo tcpServerInfo);