Added suport to Persistence and refoactoring

This commit is contained in:
Gerardo
2017-10-18 16:41:54 +02:00
parent ea5616002a
commit bc19f66812
17 changed files with 239 additions and 422 deletions
@@ -21,6 +21,11 @@ namespace MQTTnet.Implementations
return new MqttChannelCommunicationAdapter(new MqttWebSocketChannel(webSocketOptions), new MqttPacketSerializer { ProtocolVersion = options.ProtocolVersion });
}
if (options is MqttClientQueuedOptions queuedOptions)
{
return new MqttChannelCommunicationAdapter(new MqttTcpChannel(queuedOptions), new MqttPacketSerializer { ProtocolVersion = options.ProtocolVersion });
}
throw new NotSupportedException();
}
}
@@ -10,7 +10,7 @@ namespace MQTTnet
return new MqttClient(new MqttCommunicationAdapterFactory());
}
public IMqttClient CreateMqttQueuedClient()
public IMqttClientQueued CreateMqttQueuedClient()
{
return new MqttClientQueued(new MqttCommunicationAdapterFactory());
}
@@ -7,7 +7,7 @@ namespace MQTTnet.Implementations
{
public class MqttCommunicationAdapterFactory : IMqttCommunicationAdapterFactory
{
public IMqttCommunicationAdapter CreateMqttCommunicationAdapter(MqttClientOptions options)
public IMqttCommunicationAdapter CreateMqttCommunicationAdapter(MqttClientQueuedOptions options)
{
if (options == null) throw new ArgumentNullException(nameof(options));
@@ -89,7 +89,7 @@ namespace MQTTnet.Implementations
RawReceiveStream = ReceiveStream;
}
private static Certificate LoadCertificate(MqttClientOptions options)
private static Certificate LoadCertificate(MqttClientQueuedOptions options)
{
if (options.TlsOptions.Certificates == null || !options.TlsOptions.Certificates.Any())
{
@@ -9,5 +9,10 @@ namespace MQTTnet
{
return new MqttClient(new MqttCommunicationAdapterFactory());
}
public IMqttClientQueued CreateMqttQueuedClient()
{
return new MqttClientQueued(new MqttCommunicationAdapterFactory());
}
}
}