Browse Source

Merge pull request #286 from JTrotta/master

ManagedClientStorage now works
release/3.x.x
Christian 6 years ago
committed by GitHub
parent
commit
97d0286a31
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions
  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 View File

@@ -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 View File

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


Loading…
Cancel
Save