From 783ee4328aaf494a1c811d5355590f1dba280d23 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Sat, 9 Sep 2017 02:01:45 +0200 Subject: [PATCH] fixed nullpointer exception in server --- .../Implementations/MqttTcpChannel.cs | 9 +++++++++ .../Implementations/MqttTcpChannel.cs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs index 037538c..bb17ee3 100644 --- a/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs @@ -17,14 +17,23 @@ namespace MQTTnet.Implementations private Socket _socket; private SslStream _sslStream; + /// + /// called on client sockets are created in connect + /// public MqttTcpChannel() { + } + /// + /// called on server, sockets are passed in + /// connect will not be called + /// public MqttTcpChannel(Socket socket, SslStream sslStream) { _socket = socket ?? throw new ArgumentNullException(nameof(socket)); _sslStream = sslStream; + _dataStream = (Stream)sslStream ?? new NetworkStream(socket); } public async Task ConnectAsync(MqttClientOptions options) diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs index 7f59a27..068f36c 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.cs @@ -17,14 +17,22 @@ namespace MQTTnet.Implementations private Socket _socket; private SslStream _sslStream; + /// + /// called on client sockets are created in connect + /// public MqttTcpChannel() { } + /// + /// called on server, sockets are passed in + /// connect will not be called + /// public MqttTcpChannel(Socket socket, SslStream sslStream) { _socket = socket ?? throw new ArgumentNullException(nameof(socket)); _sslStream = sslStream; + _dataStream = (Stream)sslStream ?? new NetworkStream(socket); } public async Task ConnectAsync(MqttClientOptions options)