コード例 #1
0
        private static Certificate LoadCertificate(IMqttClientChannelOptions options)
        {
            if (options.TlsOptions.Certificates == null || !options.TlsOptions.Certificates.Any())
            {
                return(null);
            }

            if (options.TlsOptions.Certificates.Count > 1)
            {
                throw new NotSupportedException("Only one client certificate is supported for UWP.");
            }

            return(new Certificate(options.TlsOptions.Certificates.First().AsBuffer()));
        }
コード例 #2
0
        public IMqttChannelAdapter CreateClientAdapter(IMqttClientChannelOptions options, IMqttNetLogger logger)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            switch (options)
            {
            case MqttClientTcpOptions tcpOptions:
                return(new MqttChannelAdapter(new MqttTcpChannel(tcpOptions), new MqttPacketSerializer(), logger));

            case MqttClientWebSocketOptions webSocketOptions:
                return(new MqttChannelAdapter(new MqttWebSocketChannel(webSocketOptions), new MqttPacketSerializer(), logger));

            default:
                throw new NotSupportedException();
            }
        }
コード例 #3
0
ファイル: MqttFactory.cs プロジェクト: zhaoyingju/MQTTnet
        public IMqttCommunicationChannel CreateCommunicationChannel(IMqttClientChannelOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            switch (options)
            {
            case MqttClientTcpOptions tcpOptions:
                return(CreateTcpChannel(tcpOptions));

            case MqttClientWebSocketOptions webSocketOptions:
                return(CreateWebSocketChannel(webSocketOptions));

            default:
                throw new NotSupportedException();
            }
        }
コード例 #4
0
 public IMqttChannelAdapter CreateClientAdapter(IMqttClientChannelOptions options, IMqttNetLogger logger)
 {
     return(_adapter);
 }