Ejemplo n.º 1
0
        public MQTTPipe()
        {
            mqttClient        = new MqttFactory().CreateMqttClient();
            cancellationToken = new CancellationTokenSource();

            // 设置断线重连
            mqttClient.UseDisconnectedHandler(async e => {
                Tracker.LogNW(TAG, "disconnected");
                using (new MethodUtils.Unlocker(this)) {
                    OnDisconnectedCallback?.Invoke();
                }
                await Task.Delay(TimeSpan.FromMilliseconds(RETRY_DURATION));
                await ConnectAsync();
            });
        }
Ejemplo n.º 2
0
 private void OnDisconnected()
 {
     using (new MethodUtils.Unlocker(this)) {
         OnDisconnectedCallback?.Invoke();
     }
 }