public IMqttChannelAdapter CreateClientAdapter(MqttClientOptions options, MqttPacketInspector packetInspector, IMqttNetLogger logger) { if (options == null) { throw new ArgumentNullException(nameof(options)); } IMqttChannel channel; switch (options.ChannelOptions) { case MqttClientTcpOptions _: { channel = new MqttTcpChannel(options); break; } case MqttClientWebSocketOptions webSocketOptions: { channel = new MqttWebSocketChannel(webSocketOptions); break; } default: { throw new NotSupportedException(); } } var bufferWriter = new MqttBufferWriter(options.WriterBufferSize, options.WriterBufferSizeMax); var packetFormatterAdapter = new MqttPacketFormatterAdapter(options.ProtocolVersion, bufferWriter); return(new MqttChannelAdapter(channel, packetFormatterAdapter, packetInspector, logger)); }
public IMqttChannelAdapter CreateClientAdapter(MqttClientOptions options, MqttPacketInspector packetInspector, IMqttNetLogger logger) { if (options == null) { throw new ArgumentNullException(nameof(options)); } switch (options.ChannelOptions) { case MqttClientTcpOptions _: { return(new MqttChannelAdapter( new MqttTcpChannel(options), new MqttPacketFormatterAdapter(options.ProtocolVersion, new MqttBufferWriter(4096, 65535)), packetInspector, logger)); } case MqttClientWebSocketOptions webSocketOptions: { return(new MqttChannelAdapter( new WebSocket4NetMqttChannel(options, webSocketOptions), new MqttPacketFormatterAdapter(options.ProtocolVersion, new MqttBufferWriter(4068, 65535)), packetInspector, logger)); } default: { throw new NotSupportedException(); } } }
public IMqttChannelAdapter CreateClientAdapter(MqttClientOptions options, MqttPacketInspector packetInspector, IMqttNetLogger logger) { if (options == null) { throw new ArgumentNullException(nameof(options)); } switch (options.ChannelOptions) { case MqttClientTcpOptions tcpOptions: { var endpoint = new DnsEndPoint(tcpOptions.Server, tcpOptions.GetPort()); var tcpConnection = new TcpConnection(endpoint); var formatter = new MqttPacketFormatterAdapter(options.ProtocolVersion, new MqttBufferWriter(4096, 65535)); return(new MqttConnectionContext(formatter, tcpConnection)); } default: { throw new NotSupportedException(); } } }