mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 01:03:01 +08:00
Added MqttClientSslChannel and MqttServerSslChannel which both utilize an SSL stream. Added options to both MqttCLientOptions and MqttServerOptions. I was unable to update the code in MQTTnet.UniversalWindows due to my lack of Windows 10.
23 lines
798 B
C#
23 lines
798 B
C#
using System;
|
|
using MQTTnet.Core.Adapter;
|
|
using MQTTnet.Core.Channel;
|
|
using MQTTnet.Core.Client;
|
|
using MQTTnet.Core.Serializer;
|
|
|
|
namespace MQTTnet
|
|
{
|
|
public class MqttClientFactory
|
|
{
|
|
public MqttClient CreateMqttClient(MqttClientOptions options)
|
|
{
|
|
if (options == null) throw new ArgumentNullException(nameof(options));
|
|
|
|
return new MqttClient(options,
|
|
// The cast to IMqttCommunicationChannel is required... Roslyn is too stupid to
|
|
// figure out how to cast back to the base type
|
|
new MqttChannelCommunicationAdapter(options.UseSSL ? new MqttClientSslChannel() : (IMqttCommunicationChannel)new MqttTcpChannel(),
|
|
new DefaultMqttV311PacketSerializer()));
|
|
}
|
|
}
|
|
}
|