Ejemplo n.º 1
0
        public void Enable()
        {
            if (_isEnabled)
            {
                return;
            }

            _isEnabled = true;
            _dispatcher.Delay(_intervalMS, Tick);
        }
Ejemplo n.º 2
0
        private void OnDisconnected(object sender, MqttClientDisconnectedEventArgs args)
        {
            if (Disconnected != null)
            {
                _dispatcher.Post(() => Disconnected.Invoke(_id, sender, args));
            }

            if (_manualDisconnect)
            {
                _manualDisconnect = false;
                return;
            }
            if (!_retry)
            {
                return;
            }

            _dispatcher.Delay(RETRY_DELAY_MS, () =>
            {
                try
                {
                    if (_client != null)
                    {
                        _client.ConnectAsync(_options);
                    }
                }
                catch
                {
                    FizzLogger.E("Unable to reconnect to Fizz event service.");
                }
            });
        }
Ejemplo n.º 3
0
        private void OnDisconnected(bool clientConnected, Exception ex)
        {
            if (Disconnected != null)
            {
                _dispatcher.Post(() => Disconnected.Invoke(this, new FizzMqttDisconnectedArgs(clientConnected, ex)));
            }

            if (_manualDisconnect)
            {
                return;
            }

            if (!_retry)
            {
                return;
            }

            _dispatcher.Delay(RETRY_DELAY_MS, () => {
                try
                {
                    if (_client != null && !_manualDisconnect)
                    {
                        ConnectInternal();
                    }
                }
                catch
                {
                    FizzLogger.E("Unable to reconnect to Fizz event service.");
                }
            });
        }
Ejemplo n.º 4
0
 public FizzTimer(int delayMS, IFizzActionDispatcher dispatcher, Action onTimeout)
 {
     dispatcher.Delay(delayMS, () =>
     {
         lock (_synclock)
         {
             if (!_aborted)
             {
                 _timeout = true;
                 onTimeout();
             }
         }
     });
 }