예제 #1
0
        public void Enable()
        {
            if (_isEnabled)
            {
                return;
            }

            _isEnabled = true;
            _dispatcher.Delay(_intervalMS, Tick);
        }
예제 #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.");
                }
            });
        }
예제 #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.");
                }
            });
        }
예제 #4
0
 public FizzTimer(int delayMS, IFizzActionDispatcher dispatcher, Action onTimeout)
 {
     dispatcher.Delay(delayMS, () =>
     {
         lock (_synclock)
         {
             if (!_aborted)
             {
                 _timeout = true;
                 onTimeout();
             }
         }
     });
 }