瀏覽代碼

Merge pull request #286 from JTrotta/master

ManagedClientStorage now works
release/3.x.x
Christian 6 年之前
committed by GitHub
父節點
當前提交
97d0286a31
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 2 個文件被更改,包括 7 次插入4 次删除
  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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存