mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-11-03 21:16:59 +08:00
Fix null ref exception in UWP TCP channel
This commit is contained in:
@@ -22,6 +22,7 @@ namespace MQTTnet.Implementations
|
|||||||
public MqttTcpChannel(StreamSocket socket)
|
public MqttTcpChannel(StreamSocket socket)
|
||||||
{
|
{
|
||||||
_socket = socket ?? throw new ArgumentNullException(nameof(socket));
|
_socket = socket ?? throw new ArgumentNullException(nameof(socket));
|
||||||
|
CreateStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream SendStream { get; private set; }
|
public Stream SendStream { get; private set; }
|
||||||
@@ -54,9 +55,7 @@ namespace MQTTnet.Implementations
|
|||||||
await _socket.ConnectAsync(new HostName(options.Server), options.GetPort().ToString(), SocketProtectionLevel.Tls12);
|
await _socket.ConnectAsync(new HostName(options.Server), options.GetPort().ToString(), SocketProtectionLevel.Tls12);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendStream = _socket.OutputStream.AsStreamForWrite();
|
CreateStreams();
|
||||||
ReceiveStream = _socket.InputStream.AsStreamForRead();
|
|
||||||
RawReceiveStream = ReceiveStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task DisconnectAsync()
|
public Task DisconnectAsync()
|
||||||
@@ -80,6 +79,13 @@ namespace MQTTnet.Implementations
|
|||||||
_socket = null;
|
_socket = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateStreams()
|
||||||
|
{
|
||||||
|
SendStream = _socket.OutputStream.AsStreamForWrite();
|
||||||
|
ReceiveStream = _socket.InputStream.AsStreamForRead();
|
||||||
|
RawReceiveStream = ReceiveStream;
|
||||||
|
}
|
||||||
|
|
||||||
private static Certificate LoadCertificate(MqttClientOptions options)
|
private static Certificate LoadCertificate(MqttClientOptions options)
|
||||||
{
|
{
|
||||||
if (options.TlsOptions.Certificates == null || !options.TlsOptions.Certificates.Any())
|
if (options.TlsOptions.Certificates == null || !options.TlsOptions.Certificates.Any())
|
||||||
|
|||||||
Reference in New Issue
Block a user