Przeglądaj źródła

Merge pull request #286 from JTrotta/master

ManagedClientStorage now works
release/3.x.x
Christian 6 lat temu
committed by GitHub
rodzic
commit
97d0286a31
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 7 dodań i 4 usunięć
  1. +4
    -0
      Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClient.cs
  2. +3
    -4
      Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClientStorageManager.cs

+ 4
- 0
Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClient.cs Wyświetl plik

@@ -69,6 +69,10 @@ namespace MQTTnet.ManagedClient
{
_storageManager = new ManagedMqttClientStorageManager(_options.Storage);
await _storageManager.LoadQueuedMessagesAsync().ConfigureAwait(false);
foreach (var loadedMessage in _storageManager.ApplicationMessages)
{
_messageQueue.Add(loadedMessage);
}
}

_connectionCancellationToken = new CancellationTokenSource();


+ 3
- 4
Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClientStorageManager.cs Wyświetl plik

@@ -11,6 +11,8 @@ namespace MQTTnet.ManagedClient
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
private readonly IManagedMqttClientStorage _storage;

public List<MqttApplicationMessage> ApplicationMessages => _applicationMessages;

public ManagedMqttClientStorageManager(IManagedMqttClientStorage storage)
{
_storage = storage ?? throw new ArgumentNullException(nameof(storage));
@@ -19,10 +21,7 @@ namespace MQTTnet.ManagedClient
public async Task LoadQueuedMessagesAsync()
{
var loadedMessages = await _storage.LoadQueuedMessagesAsync().ConfigureAwait(false);
foreach (var loadedMessage in loadedMessages)
{
_applicationMessages.Add(loadedMessage);
}
_applicationMessages.AddRange(loadedMessages);
}

public async Task AddAsync(MqttApplicationMessage applicationMessage)


Ładowanie…
Anuluj
Zapisz