Ejemplo n.º 1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                List<ushort> list = new List<ushort>();

                KeyValuePair<ushort, RetryMessageData>[] kvps = container.Where(c =>
                    c.Value.NextRetryTime < DateTime.UtcNow
                    && c.Value.Direction == DirectionType.Out).ToArray();

                if (kvps.Length > 0)
                {
                    foreach (var item in kvps)
                    {
                        item.Value.Increment(config.AckTimeout);
                        container[item.Key] = item.Value;

                        if (item.Value.AttemptCount >= config.MaxRetransmit)
                        {
                            list.Add(item.Key);
                        }
                        else
                        {
                            OnRetry?.Invoke(this, new MqttMessageEventArgs(item.Value.Message));
                        }
                    }
                }

                foreach (var item in list)
                    Remove(item);
            }
            catch { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Signals a retry
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void Quarantine_OnRetry(object sender, MqttMessageEventArgs args)
        {
            MqttMessage msg = args.Message;

            msg.Dup = true;
            OnRetry?.Invoke(this, new MqttMessageEventArgs(msg));
        }
Ejemplo n.º 3
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            List <ushort> list = new List <ushort>();


            IEnumerable <KeyValuePair <ushort, RetryMessageData> > items = container.Where((c) => c.Value.NextRetryTime < DateTime.UtcNow &&
                                                                                           c.Value.Direction == DirectionType.Out);

            if (items != null && items.Count() > 0)
            {
                foreach (var item in items.ToArray())
                {
                    item.Value.Increment(config.AckTimeout);
                    container[item.Key] = item.Value;

                    if (item.Value.AttemptCount >= config.MaxRetransmit)
                    {
                        //add expired items to list to be removed
                        list.Add(item.Key);
                    }
                    else
                    {
                        //signal retransmit
                        OnRetry?.Invoke(this, new MqttMessageEventArgs(item.Value.Message));
                    }
                }
            }

            //remove expired items
            foreach (var item in list)
            {
                Remove(item);
            }
        }
        private async void OnTimerElapsed(object sender, EventArgs e)
        {
            var tmp = MessageTasks.Peek();

            try
            {
                var rsp = await tmp();

                if (rsp.IsSuccessStatusCode)
                {
                    MessageTasks.Dequeue();
                    EnqueueCallback(TimeSpan.FromMilliseconds(100).TotalMilliseconds);
                }
                else
                {
                    EnqueueCallback(TimeSpan.FromSeconds(20).TotalMilliseconds);
                    OnRetry?.Invoke($"Не удалось отправить сообщение({rsp.StatusCode.ToString()}). Следующая попыдка через 20 сек");
                }
            }
            catch (HttpRequestException ex)
            {
                EnqueueCallback(TimeSpan.FromSeconds(20).TotalMilliseconds);
                OnRetry?.Invoke($"Произошла ошибка соединения({ex.InnerException?.Message}) Следующая попытка через 20 сек");
            }
        }
Ejemplo n.º 5
0
        private void load(OsuColour colours)
        {
            AddButton("Continue", colours.Green, () => OnResume?.Invoke());
            AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
            AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());

            AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
            {
                Looping = true,
                Volume  = { Value = 0 }
            });
        }
Ejemplo n.º 6
0
        public void HandleRetry(Exception ex, int retryCount, long elapsedMilliseconds)
        {
            var eventType = string.Format("{0}_Retry", eventName);
            var message   = string.Format("Retry event {0}, Retries {1}, Exception Type {2}", ex.GetType().Name, eventName, ex.GetType());

            if (OnRetry != null)
            {
                OnRetry.Invoke(ex);
            }

            TraceEvent(eventType, message, retryCount, elapsedMilliseconds);
        }
Ejemplo n.º 7
0
        public void InvokeRetry()
        {
            EventBinder <Action> onDispose = new EventBinder <Action>(e => OnSoftDispose += e, e => OnSoftDispose -= e);

            onDispose.IsOneTime = true;
            onDispose.SetHandler(() =>
            {
                OnRetry?.Invoke();
                InvokeSoftInit();
            });
            InvokeSoftDispose();
        }
Ejemplo n.º 8
0
        private void load(OsuColour colours)
        {
            AddButton("Continue", colours.Green, () => OnResume?.Invoke());
            AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
            AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());

            AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop"))
            {
                Looping = true,
            });

            // SkinnableSound only plays a sound if its aggregate volume is > 0, so the volume must be turned up before playing it
            pauseLoop.VolumeTo(minimum_volume);
        }
Ejemplo n.º 9
0
        public override async Task OnSent(HttpSentContext context)
        {
            if (!RetryValidator(context))
            {
                return;
            }

            var uri = context.Uri;

            var retryCount = context.Items["RetryCount"].As <int?>().GetValueOrDefault();

            if (retryCount >= MaxAutoRetries)
            {
                return;
            }

            var retryAfter = GetRetryAfter(context.Result);

            var ctx = new RetryContext
            {
                StatusCode        = context.Result.StatusCode,
                RequestMessage    = context.Result.RequestMessage,
                Uri               = uri,
                ShouldRetry       = retryAfter.HasValue,
                RetryAfter        = retryAfter ?? DefaultRetryAfter,
                CurrentRetryCount = retryCount
            };

            OnRetry?.Invoke(ctx);

            if (!ctx.ShouldRetry)
            {
                return;
            }

            if (ctx.RetryAfter > TimeSpan.Zero)
            {
                await Task.Delay(ctx.RetryAfter, context.Token);
            }

            context.Items["RetryCount"] = retryCount + 1;

            // dispose of previous response
            ObjectHelpers.Dispose(context.Result);

            context.Result = await context.Builder.RecursiveResultAsync(context.Token);
        }
Ejemplo n.º 10
0
        private void ExecuteAsync()
        {
            while (!ShutDown)
            {
                Thread.Sleep(100);
                if (Idle)
                {
                    Idle = false;
                    if (ip == null)
                    {
                        ShutDown = true;
                        return;
                    }
                    foreach (var port in ports)
                    {
                        try
                        {
                            Debug.Print(ip);
                            HttpWebRequest request = WebRequest.Create(ip) as HttpWebRequest;
                            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
                            request.Proxy     = new WebProxy(proxy.ip, proxy.port);
                            HttpWebResponse     response = (HttpWebResponse)request.GetResponse();
                            WebHeaderCollection header   = response.Headers;
                            var encoding = ASCIIEncoding.ASCII;
                            using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
                            {
                                string responseText = reader.ReadToEnd();
                                Debug.Print(responseText);
                                // Console.ReadLine();
                                if (responseText.Contains("ERROR:101"))
                                {
                                    OnRespnse?.Invoke(this, true);
                                }
                            }
                        }
                        catch (Exception)
                        {
                            OnRetry?.Invoke(ip);
                        }
                    }

                    OnRespnse?.Invoke(this, false);
                }
            }
        }
Ejemplo n.º 11
0
        private void load(OsuColour colours)
        {
            AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
            AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());

            Add(new Container
            {
                Anchor           = Anchor.BottomLeft,
                Origin           = Anchor.BottomLeft,
                RelativeSizeAxes = Axes.X,
                Height           = TwoLayerButton.SIZE_EXTENDED.Y,
                Children         = new Drawable[]
                {
                    new Box
                    {
                        RelativeSizeAxes = Axes.Both,
                        Colour           = Color4Extensions.FromHex("#333")
                    },
                    new FillFlowContainer
                    {
                        Anchor           = Anchor.Centre,
                        Origin           = Anchor.Centre,
                        AutoSizeAxes     = Axes.X,
                        RelativeSizeAxes = Axes.Y,
                        Spacing          = new Vector2(5),
                        Padding          = new MarginPadding(10),
                        Direction        = FillDirection.Horizontal,
                        Children         = new Drawable[]
                        {
                            new SaveScoreButton()
                            {
                                OnSave           = OnSave,
                                RelativeSizeAxes = Axes.Y,
                                Width            = 300
                            },
                        }
                    }
                }
            });
        }
Ejemplo n.º 12
0
        private async Task RetryConnectionAsync()
        {
            _tokenSource.Cancel(false);

            if (_connectionAttempts > _lavaConfig.ReconnectAttempts && _lavaConfig.ReconnectAttempts != -1)
            {
                return;
            }

            if (Volatile.Read(ref _refIsUsable))
            {
                return;
            }

            Interlocked.Increment(ref _connectionAttempts);
            _reconnectInterval += _lavaConfig.ReconnectDelay;
            OnRetry?.Invoke(_connectionAttempts == _lavaConfig.ReconnectAttempts
                ? "This was the last attempt at re-establishing websocket connection."
                : $"Waiting {_reconnectInterval.TotalSeconds}s before attempt #{_connectionAttempts}.");

            await Task.Delay(_reconnectInterval)
            .ContinueWith(_ => ConnectAsync())
            .ConfigureAwait(false);
        }
Ejemplo n.º 13
0
 // ------------------- Button Functions ------------------------//
 public void RetryButton()
 {
     OnRetry?.Invoke();
 }
Ejemplo n.º 14
0
 private void load(OsuColour colours)
 {
     AddButton("Continue", colours.Green, () => OnResume?.Invoke());
     AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
     AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
 }
Ejemplo n.º 15
0
 private void Transmit_OnRetry(object sender, CoapMessageEventArgs e)
 {
     OnRetry?.Invoke(this, e);
 }
Ejemplo n.º 16
0
 //assign this in the editor
 //this structure seems redundant but helps a lot in tracking through code
 public void Click()
 {
     OnRetry?.Invoke();
 }
Ejemplo n.º 17
0
 private void load(OsuColour colours)
 {
     AddButton("重新開始", colours.YellowDark, () => OnRetry?.Invoke());
     AddButton("離開", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
 }
Ejemplo n.º 18
0
 private void load()
 {
     AddButton("Retry", RhythmicColors.FromHex(@"eeaa00"), () => OnRetry?.Invoke());
     AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
 }
Ejemplo n.º 19
0
 public void OnClickRetry()
 {
     OnRetry?.Invoke(this, EventArgs.Empty);
 }