Просмотр исходного кода

Fix subscription handling of _ManagedClient_.

release/3.x.x
Christian 6 лет назад
Родитель
Сommit
b3a25fb9e8
1 измененных файлов: 13 добавлений и 3 удалений
  1. +13
    -3
      Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClient.cs

+ 13
- 3
Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClient.cs Просмотреть файл

@@ -45,6 +45,7 @@ namespace MQTTnet.ManagedClient
public event EventHandler<MqttClientDisconnectedEventArgs> Disconnected;
public event EventHandler<MqttApplicationMessageReceivedEventArgs> ApplicationMessageReceived;
public event EventHandler<ApplicationMessageProcessedEventArgs> ApplicationMessageProcessed;
public event EventHandler SynchronizingSubscriptionsFailed;

public async Task StartAsync(IManagedMqttClientOptions options)
{
@@ -309,13 +310,22 @@ namespace MQTTnet.ManagedClient

try
{
await _mqttClient.SubscribeAsync(subscriptions).ConfigureAwait(false);
await _mqttClient.UnsubscribeAsync(unsubscriptions).ConfigureAwait(false);
if (subscriptions.Any())
{
await _mqttClient.SubscribeAsync(subscriptions).ConfigureAwait(false);
}

if (unsubscriptions.Any())
{
await _mqttClient.UnsubscribeAsync(unsubscriptions).ConfigureAwait(false);
}
}
catch (Exception exception)
{
_logger.Warning<ManagedMqttClient>(exception, "Synchronizing subscriptions failed");
_logger.Warning<ManagedMqttClient>(exception, "Synchronizing subscriptions failed.");
_subscriptionsNotPushed = true;

SynchronizingSubscriptionsFailed?.Invoke(this, EventArgs.Empty);
}
}



Загрузка…
Отмена
Сохранить