Procházet zdrojové kódy

Merge pull request #286 from JTrotta/master

ManagedClientStorage now works
release/3.x.x
Christian před 6 roky
committed by GitHub
rodič
revize
97d0286a31
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 4AEE18F83AFDEB23
2 změnil soubory, kde provedl 7 přidání a 4 odebrání
  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 Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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)


Načítá se…
Zrušit
Uložit