Пример #1
0
 public override void StartTimer()
 {
     if (RetryIn.HasValue)
     {
         _timer.Start(RetryIn.Value, OnTimeOut);
     }
 }
Пример #2
0
 /// <summary>
 /// Checks to see if the hands are in the starting position and in the "play area"
 /// before enabling control. Control is disabled if the hands drop outside the "play area.
 /// </summary>
 /// <param name="handsMidpoint">Vector representing the 3D midpoint of the hands.</param>
 /// <param name="spineYPosition">The Y position of the spine.</param>
 /// <param name="leftHand">Vector representing the 3D position of the left hand.</param>
 /// <param name="rightHand">Vector representing the 3D position of the right hand.</param>
 /// <returns>Whether the user can control the car or not.</returns>
 private void EnableDisableControl(Vector3D handsMidpoint, double spineYPosition, Vector3D leftHand, Vector3D rightHand)
 {
     // if we are not controlling
     if (!_isControlling)
     {
         // if the hands are horizontal and in the play area
         if (HandsStable(leftHand, rightHand) && HandsInPlayArea(handsMidpoint, spineYPosition))
         {
             // if the timer hasn't already been started
             if (!_countdownTimer.IsEnabled)
             {
                 // start the timer
                 _countdownTimer.Start();
             }
         }
         // if the hands are not horizontal or in the play area
         else
         {
             // reset
             DisableControl();
         }
     }
     // if we are controlling
     else
     {
         // if the hands are not in the play area
         if (!HandsInPlayArea(handsMidpoint, spineYPosition))
         {
             // stop controlling
             DisableControl();
         }
     }
 }
 public override void StartTimer()
 {
     if (RetryInstantly == false)
     {
         _timer.Start(Context.RetryTimeout, OnTimeOut);
     }
 }
Пример #4
0
 public override void StartTimer()
 {
     if (_connectedTransport)
     {
         _timer.Start(TimeSpan.FromMilliseconds(CloseTimeout), OnTimeOut);
     }
 }
Пример #5
0
        void IConfigChangeHandler.ConfigUpdated(ConfigSettings newSettings)
        {
            lock (_countdownTimer)
            {
                if (newSettings.ShowCountdown != _countdownTimer.IsSwitchedOn)
                {
                    if (newSettings.ShowCountdown)
                    {
                        _countdownTimer.SwitchOn();
                        _countdownTimer.Start();
                    }
                    else
                    {
                        _countdownTimer.Stop();
                        _countdownTimer.SwitchOff();
                    }

                    _view.Invoke(() =>
                    {
                        _countdownTimer.Execute();                              // ensure the countdown is set/executed before making visible
                        _view.ShowCountdown(newSettings.ShowCountdown);
                    });
                }
            }
        }
 public override Task OnAttachToContext()
 {
     if (RetryIn.HasValue)
     {
         _timer.Start(RetryIn.Value, OnTimeOut);
     }
     return(TaskConstants.BooleanTrue);
 }
Пример #7
0
 public override void OnAttachedToContext()
 {
     if (this.context.Transport.State == TransportState.Connected)
     {
         this.context.Transport.Send(new ProtocolMessage(ProtocolMessage.MessageAction.Close));
         _timer.Start(CloseTimeout, () => this.context.SetState(new ConnectionClosedState(this.context)));
     }
     else
     {
         this.context.SetState(new ConnectionClosedState(this.context));
     }
 }
        public override Task OnAttachToContext()
        {
            // This is a terminal state. Clear the transport.
            Context.ClearAckQueueAndFailMessages(ErrorInfo.ReasonSuspended);

            if (RetryIn.HasValue)
            {
                _timer.Start(RetryIn.Value, OnTimeOut);
            }

            return(TaskConstants.BooleanTrue);
        }
        public override async Task OnAttachToContext()
        {
            // RTN15g - If a client has been disconnected for longer
            // than the connectionStateTtl, it should not attempt to resume.
            if (Context.Connection.ConfirmedAliveAt?.Add(Context.Connection.ConnectionStateTtl) < DateTimeOffset.UtcNow)
            {
                Context.Connection.Id  = string.Empty;
                Context.Connection.Key = string.Empty;
            }

            await Context.CreateTransport();

            _timer.Start(Context.DefaultTimeout, onTimeOut: OnTimeOut);
        }
Пример #10
0
        public override Task OnAttachToContext()
        {
            Context.DestroyTransport();

            if (RetryInstantly)
            {
                Context.SetState(new ConnectionConnectingState(Context));
            }
            else
            {
                _timer.Start(Context.RetryTimeout, OnTimeOut);
            }

            return(TaskConstants.BooleanTrue);
        }
Пример #11
0
        public override Task OnAttachToContext()
        {
            var transport = Context.Transport;

            if (transport?.State == TransportState.Connected)
            {
                Context.SendToTransport(new ProtocolMessage(ProtocolMessage.MessageAction.Close));
                _timer.Start(TimeSpan.FromMilliseconds(CloseTimeout), OnTimeOut);
            }
            else
            {
                Context.SetState(new ConnectionClosedState(Context));
            }
            return(TaskConstants.BooleanTrue);
        }
Пример #12
0
        public override Task OnAttachToContext()
        {
            Context.DestroyTransport();

            if (Logger.IsDebug)
            {
                Logger.Debug("RetryInstantly set to '" + RetryInstantly + "'");
            }
            if (RetryInstantly)
            {
                Context.SetState(new ConnectionConnectingState(Context, Logger));
            }
            else
            {
                _timer.Start(Context.RetryTimeout, OnTimeOut);
            }

            return(TaskConstants.BooleanTrue);
        }
Пример #13
0
        void DataFetched(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    _fetchExceptionHandler.Handle(e.Error);
                    return;
                }

                var xmlResults = e.Result as IEnumerable <string>;
                IEnumerable <ProjectStatus> projectData = new List <ProjectStatus>();
                if (xmlResults != null)
                {
                    projectData = xmlResults.SelectMany(xml =>
                    {
                        try
                        {
                            return(_transformer.Transform(xml));
                        }
                        catch (Exception exception)
                        {
                            _log.Error(exception);
                            return(new List <ProjectStatus>());
                        }
                    });
                }

                _view.DataContext = new ViewModels.ViewDataViewModel(_viewSettings, projectData);

                _discJockey.PlaySounds(projectData);
            }
            finally
            {
                _view.ShowProgress = false;

                _pollTimer.Start();
                _countdownTimer.Reset();
                _countdownTimer.Start();
            }
        }
        public override void OnAttachedToContext()
        {
            context.AttemptConnection();

            if (context.Transport == null || _useFallbackHost)
            {
                context.CreateTransport(_useFallbackHost);
            }

            if (context.Transport.State != TransportState.Connected)
            {
                this.context.Transport.Connect();
                _timer.Start(ConnectTimeout, () =>
                {
                    this.context.SetState(new ConnectionDisconnectedState(this.context, ErrorInfo.ReasonTimeout)
                    {
                        UseFallbackHost = AblyBase.CanConnectToAbly()
                    });
                });
            }
        }
Пример #15
0
        private ConnectionHeartbeatRequest Send(Action <TimeSpan?, ErrorInfo> callback)
        {
            _start = Now();

            if (_manager.Connection.State != ConnectionState.Connected)
            {
                callback?.Invoke(default(TimeSpan), DefaultError);

                return(this);
            }

            if (callback != null)
            {
                _callback = callback;
                _manager.MessageReceived += OnMessageReceived;
                _manager.Connection.InternalStateChanged += OnInternalStateChanged;

                _manager.Send(new ProtocolMessage(ProtocolMessage.MessageAction.Heartbeat), null);
                _timer.Start(_manager.DefaultTimeout, () => FinishRequest(null, TimeOutError));
            }

            return(this);
        }
Пример #16
0
 public override void StartTimer()
 {
     _timer.Start(Context.DefaultTimeout, onTimeOut: OnTimeOut);
 }
Пример #17
0
        public override async Task OnAttachToContext()
        {
            await Context.CreateTransport();

            _timer.Start(Context.DefaultTimeout, onTimeOut: OnTimeOut);
        }