Example #1
0
        public McAfeeApi(IMcAfeeConfiguration configuration)
        {
            Guard.AgainstNull(configuration, nameof(configuration));

            _configuration = configuration;
            _url           = configuration.Url;

            if (!_url.EndsWith("/"))
            {
                _url += "/";
            }

            _client = new RestClient(configuration.Url);

            _client.AddDefaultHeader("Accept", "application/vnd.ve.v1.0+json");

            var cancellationToken = _cancellationTokenSource.Token;

            _task = Task.Run(() =>
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    Heartbeat();

                    ThreadSleep.While(1000, cancellationToken);

                    if (DateTime.Now > _nextLogin)
                    {
                        Logout();
                    }
                }
            });

            _log = Log.For(this);
        }
Example #2
0
        public override void DoWork()
        {
            while (Global.LocalPlayer == null)
            {
                Thread.Sleep(500);
            }

            Global.LocalPlayer.AfterShotFire += (sender, args) =>
            {
                Global.LocalPlayer.SendPackets = false;
                Global.LocalPlayer.ViewAngle   = RCS.NewViewAngle().NormalizeAngle();
                Thread.Sleep(10);
                Global.LocalPlayer.SendPackets = true;
            };

            while (true)
            {
                if (!Enabled || Global.ProcessState != ProcessState.Attached || Global.LocalPlayer == null)
                {
                    Thread.Sleep(1000);
                    continue;
                }


                if (Key == 0 || Keyboard.IsPressed(Key))
                {
                    if (CanShoot())
                    {
                        TriggerPattern();
                    }
                }

                ThreadSleep.Set(FunctionName);
            }
        }
        public override void DoWork()
        {
            while (true)
            {
                if (!Enabled || Global.ProcessState != ProcessState.Attached)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                var state = Global.LocalPlayer.State;

                if (Keyboard.IsPressed(0x20))
                {
                    _bunny.Handle();
                    if (Global.LocalPlayer.IsReloading)
                    {
                        Console.WriteLine("reload");
                    }

                    ThreadSleep.Set(FunctionName);
                    continue;
                }
                if (state != PlayerState.Jump && state != PlayerState.DuckJump)
                {
                    _bunny.ManualReset();
                }

                Thread.Sleep(5);
            }
        }
Example #4
0
        public override void DoWork()
        {
            while (true)
            {
                if (Global.LocalPlayer == null || Global.ProcessState != ProcessState.Attached || !Enabled)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                if (Keyboard.IsPressed(1))
                {
                    var lPlayer = Global.LocalPlayer;
                    var wpn     = lPlayer.Inventory.ActiveWeapon.TypeOfWeapon();
                    if (wpn != WeaponType.Pistol && lPlayer.Inventory.ActiveWeapon.Name != "AWP" &&
                        wpn != WeaponType.Knife && wpn != WeaponType.Shotgun)
                    {
                        if (lPlayer.ShotsFired >= 1)
                        {
                            lPlayer.ViewAngle = RCS.NewViewAngle().NormalizeAngle();
                        }
                        _reset = true;
                    }
                }
                else if (_reset)
                {
                    _reset = false;
                    RCS.HardReset();
                }

                ThreadSleep.Set(FunctionName);
            }
        }
Example #5
0
        public void ExecuteAllPendingLazyOperations()
        {
            if (pendingLazyOperations.Count == 0)
            {
                return;
            }

            try
            {
                IncrementRequestCount();
                while (ExecuteLazyOperationsSingleStep())
                {
                    ThreadSleep.Sleep(100);
                }

                foreach (var pendingLazyOperation in pendingLazyOperations)
                {
                    Action <object> value;
                    if (onEvaluateLazy.TryGetValue(pendingLazyOperation, out value))
                    {
                        value(pendingLazyOperation.Result);
                    }
                }
            }
            finally
            {
                pendingLazyOperations.Clear();
            }
        }
Example #6
0
        public ResponseTimeInformation ExecuteAllPendingLazyOperations()
        {
            if (pendingLazyOperations.Count == 0)
            {
                return(new ResponseTimeInformation());
            }

            try
            {
                var sw = Stopwatch.StartNew();
                IncrementRequestCount();
                var responseTimeDuration = new ResponseTimeInformation();
                while (ExecuteLazyOperationsSingleStep())
                {
                    ThreadSleep.Sleep(100);
                }
                responseTimeDuration.ComputeServerTotal();

                foreach (var pendingLazyOperation in pendingLazyOperations)
                {
                    Action <object> value;
                    if (onEvaluateLazy.TryGetValue(pendingLazyOperation.Item1, out value))
                    {
                        value(pendingLazyOperation.Item1.Result);
                    }
                }

                responseTimeDuration.TotalClientDuration = sw.Elapsed;
                return(responseTimeDuration);
            }
            finally
            {
                pendingLazyOperations.Clear();
            }
        }
 private void Worker()
 {
     while (!_cancellationTokenSource.IsCancellationRequested)
     {
         Console.WriteLine($"[working] : {DateTime.Now:O}");
         ThreadSleep.While(1000, _cancellationTokenSource.Token);
     }
 }
        public void Execute(IThreadState state)
        {
            if (!ShouldProcessDeferred())
            {
                ThreadSleep.While(1000, state);

                return;
            }

            var pipeline = _pipelineFactory.GetPipeline<DeferredMessagePipeline>();

            try
            {
                pipeline.State.ResetWorking();

                pipeline.Execute();

                if (pipeline.State.GetWorking())
                {
                    var transportMessage = pipeline.State.GetTransportMessage();

                    if (transportMessage.IgnoreTillDate < _ignoreTillDate)
                    {
                        _ignoreTillDate = transportMessage.IgnoreTillDate;
                    }

                    if (!_checkpointMessageId.Equals(transportMessage.MessageId))
                    {
                        if (!Guid.Empty.Equals(_checkpointMessageId))
                        {
                            return;
                        }

                        _checkpointMessageId = transportMessage.MessageId;

                        _log.Trace(string.Format(Resources.TraceDeferredCheckpointMessageId,
                            transportMessage.MessageId));

                        return;
                    }
                }

                _nextDeferredProcessDate = _ignoreTillDate;
                _ignoreTillDate = DateTime.MaxValue;
                _checkpointMessageId = Guid.Empty;

                _log.Trace(_nextDeferredProcessDate.Equals(DateTime.MaxValue)
                    ? Resources.TraceDeferredProcessingHalted
                    : string.Format(Resources.TraceDeferredProcessingReset, _nextDeferredProcessDate.ToString("O")));
            }
            finally
            {
                _pipelineFactory.ReleasePipeline(pipeline);
            }
        }
Example #9
0
        public void Execute(OnPipelineStarting pipelineEvent)
        {
            const int SLEEP = 15000;

            if (_activeTimeRange.Active())
            {
                return;
            }

            pipelineEvent.Pipeline.Abort();

            ThreadSleep.While(SLEEP, _state);
        }
Example #10
0
        public void Execute(OnPipelineStarting pipelineEvent)
        {
            const int sleep = 15000;

            if (_activeTimeRange.Active())
            {
                return;
            }

            pipelineEvent.Pipeline.Abort();

            ThreadSleep.While(sleep, pipelineEvent.Pipeline.State.GetCancellationToken());
        }
        private void SequenceNumberTailThreadWorker()
        {
            while (_started)
            {
                lock (_lock)
                {
                    foreach (var projectionAggregation in _projectionAggregations)
                    {
                        projectionAggregation.Value.ProcessSequenceNumberTail();
                    }
                }

                ThreadSleep.While(_configuration.SequenceNumberTailThreadWorkerInterval, _cancellationToken);
            }
        }
        private void Send()
        {
            while (_active)
            {
                if (_sentinelConfiguration.Enabled && _nextSendDate <= DateTime.Now)
                {
                    _bus.Send(_endpointAggregator.GetRegisterEndpointCommand());

                    _nextSendDate = DateTime.Now.Add(_sentinelConfiguration.HeartbeatIntervalDuration);
                }

                ThreadSleep.While(1000, this);
            }

            _thread.Join(TimeSpan.FromSeconds(5));
        }
Example #13
0
        public void Execute(IThreadState state)
        {
            if (!ShouldProcessDeferred())
            {
                ThreadSleep.While(1000, state);

                return;
            }

            lock (_messageDeferredLock)
            {
                _messageDeferred = false;
            }

            var pipeline = _bus.Configuration.PipelineFactory.GetPipeline <DeferredMessagePipeline>(_bus);

            pipeline.State.SetCheckpointMessageId(_checkpointMessageId);
            pipeline.State.SetNextDeferredProcessDate(_nextDeferredProcessDate);
            pipeline.State.SetDeferredMessageReturned(false);

            pipeline.Execute();

            var nextDeferredProcessDate = pipeline.State.Get <DateTime>(StateKeys.NextDeferredProcessDate);

            if (_messageDeferred)
            {
                if (nextDeferredProcessDate < _nextDeferredProcessDate)
                {
                    _nextDeferredProcessDate = nextDeferredProcessDate;
                }
            }
            else
            {
                _nextDeferredProcessDate = nextDeferredProcessDate;
            }

            if (_checkpointMessageId != pipeline.State.Get <Guid>(StateKeys.CheckpointMessageId))
            {
                _checkpointMessageId = pipeline.State.Get <Guid>(StateKeys.CheckpointMessageId);

                return;
            }

            _checkpointMessageId = Guid.Empty;
        }
Example #14
0
        public void Execute(CancellationToken cancellationToken)
        {
            if (!ShouldProcessDeferred())
            {
                ThreadSleep.While(1000, cancellationToken);

                return;
            }

            var pipeline = _pipelineFactory.GetPipeline <DeferredMessagePipeline>();

            try
            {
                pipeline.State.ResetWorking();
                pipeline.State.SetDeferredMessageReturned(false);
                pipeline.State.SetTransportMessage(null);

                pipeline.Execute();

                var transportMessage = pipeline.State.GetTransportMessage();

                if (pipeline.State.GetDeferredMessageReturned())
                {
                    if (transportMessage != null &&
                        transportMessage.MessageId.Equals(_checkpointMessageId))
                    {
                        _checkpointMessageId = Guid.Empty;
                    }

                    return;
                }

                if (pipeline.State.GetWorking() && transportMessage != null)
                {
                    if (transportMessage.IgnoreTillDate < _ignoreTillDate)
                    {
                        _ignoreTillDate = transportMessage.IgnoreTillDate;
                    }

                    if (!_checkpointMessageId.Equals(transportMessage.MessageId))
                    {
                        if (!_checkpointMessageId.Equals(Guid.Empty))
                        {
                            return;
                        }

                        _checkpointMessageId = transportMessage.MessageId;

                        _log.Trace(string.Format(Resources.TraceDeferredCheckpointMessageId,
                                                 transportMessage.MessageId));

                        return;
                    }
                }

                lock (_messageDeferredLock)
                {
                    _nextDeferredProcessDate = _ignoreTillDate;
                }

                _ignoreTillDate      = DateTime.MaxValue;
                _checkpointMessageId = Guid.Empty;

                _log.Trace(_nextDeferredProcessDate.Equals(DateTime.MaxValue)
                    ? Resources.TraceDeferredProcessingHalted
                    : string.Format(Resources.TraceDeferredProcessingReset, _nextDeferredProcessDate.ToString("O")));
            }
            finally
            {
                _pipelineFactory.ReleasePipeline(pipeline);
            }
        }
Example #15
0
        public void Waiting(IThreadState state)
        {
            var ms = (int)GetSleepTimeSpan().TotalMilliseconds;

            ThreadSleep.While(ms, state);
        }
        public override void DoWork()
        {
            while (true)
            {
                if (Global.ProcessState != ProcessState.Attached && Global.LocalPlayer == null)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                var lPlayer = Global.LocalPlayer;

                if (RadarSpottedEnabled && radarTimer <= DateTime.Now)
                {
                    foreach (var player in Global.Players.Where(x => !x.IsAlly))
                    {
                        if (player.IsAlive)
                        {
                            player.Spotted = true;
                        }
                    }


                    radarTimer            = DateTime.Now.AddMilliseconds(ThreadSleep.Get("Radar"));
                    lPlayer.FlashMaxAlpha = 255f * (FlashbangAlphaPercentage / 100);
                }

                if (!FOVEnabled)
                {
                    Thread.Sleep(1000);
                    continue;
                }

                if (lPlayer.Inventory.ActiveWeapon.TypeOfWeapon() == WeaponType.Sniper)
                {
                    continue;
                }

                if ((Keyboard.IsPressed(FOVKey) || FOVKey == 0))
                {
                    if (lPlayer.FOV != FOV)
                    {
                        for (int i = 0; i < 1750; i++) //flood to bruteforce FOV (the only way probably)
                        {
                            lPlayer.FOV = FOV;
                        }
                        continue;
                    }
                }
                else
                {
                    if (lPlayer.FOV != 0)
                    {
                        for (int i = 0; i < 1750; i++) //flood to bruteforce FOV (the only way probably)
                        {
                            lPlayer.FOV = 0;
                        }
                        continue;
                    }
                }

                Thread.Sleep(10);
            }
        }
Example #17
0
        protected override Task <QueryOperation> ExecuteActualQueryAsync()
        {
            var results = CompletedTask.With(new bool[ShardDatabaseCommands.Count]).Task;

            Func <Task> loop = null;

            loop = () =>
            {
                var lastResults = results.Result;

                results = shardStrategy.ShardAccessStrategy.ApplyAsync(ShardDatabaseCommands,
                                                                       new ShardRequestData
                {
                    EntityType = typeof(T),
                    Query      = IndexQuery,
                    IndexName  = indexName
                }, (commands, i) =>
                {
                    if (lastResults[i])                             // if we already got a good result here, do nothing
                    {
                        return(CompletedTask.With(true));
                    }

                    var queryOp = shardQueryOperations[i];

                    var queryContext = queryOp.EnterQueryContext();
                    return(commands.QueryAsync(indexName, queryOp.IndexQuery, includes.ToArray())
                           .ContinueWith(task =>
                    {
                        if (queryContext != null)
                        {
                            queryContext.Dispose();
                        }

                        return queryOp.IsAcceptable(task.Result);
                    }));
                });

                return(results.ContinueWith(task =>
                {
                    task.AssertNotFailed();

                    if (lastResults.All(acceptable => acceptable))
                    {
                        return new CompletedTask().Task;
                    }


                    ThreadSleep.Sleep(100);

                    return loop();
                }).Unwrap());
            };

            return(loop().ContinueWith(task =>
            {
                task.AssertNotFailed();

#if !NETFX_CORE
                ShardedDocumentQuery <T> .AssertNoDuplicateIdsInResults(shardQueryOperations);
#endif

                var mergedQueryResult = shardStrategy.MergeQueryResults(IndexQuery, shardQueryOperations.Select(x => x.CurrentQueryResults).ToList());

                shardQueryOperations[0].ForceResult(mergedQueryResult);
                queryOperation = shardQueryOperations[0];

                return queryOperation;
            }));
        }
Example #18
0
 public PocThreadSleep()
 {
     threadSleep = new ThreadSleep();
 }