Refactor options and add options builder

This commit is contained in:
Christian Kratky
2017-10-25 22:33:07 +02:00
parent a9b394401b
commit a18c533603
27 changed files with 448 additions and 233 deletions
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MQTTnet.Core.Client;
namespace MQTTnet.Core.ManagedClient
{
public interface IManagedMqttClient : IApplicationMessageReceiver, IApplicationMessagePublisher
{
bool IsConnected { get; }
event EventHandler<MqttClientConnectedEventArgs> Connected;
event EventHandler<MqttClientDisconnectedEventArgs> Disconnected;
Task StartAsync(IManagedMqttClientOptions options);
Task StopAsync();
Task SubscribeAsync(IEnumerable<TopicFilter> topicFilters);
Task UnsubscribeAsync(IEnumerable<TopicFilter> topicFilters);
}
}
@@ -11,7 +11,7 @@ using Microsoft.Extensions.Logging;
namespace MQTTnet.Core.ManagedClient
{
public class ManagedMqttClient : IApplicationMessageReceiver
public class ManagedMqttClient : IManagedMqttClient
{
private readonly ManagedMqttClientStorageManager _storageManager = new ManagedMqttClientStorageManager();
private readonly BlockingCollection<MqttApplicationMessage> _messageQueue = new BlockingCollection<MqttApplicationMessage>();
@@ -91,7 +91,7 @@ namespace MQTTnet.Core.ManagedClient
return Task.FromResult(0);
}
public Task EnqueueAsync(IEnumerable<MqttApplicationMessage> applicationMessages)
public Task PublishAsync(IEnumerable<MqttApplicationMessage> applicationMessages)
{
if (applicationMessages == null) throw new ArgumentNullException(nameof(applicationMessages));