From 9c378fb08859ddf05bbdfc06a39983ae0c352cb5 Mon Sep 17 00:00:00 2001 From: Jim Schaad Date: Tue, 31 Dec 2019 14:44:25 -0800 Subject: [PATCH] Provide the full ACK on a connection failure There are some systems that return information on a failed exception and thus the client wants access to the full set of ACK information. Specifically the user properties. --- Source/MQTTnet/Adapter/MqttConnectingFailedException.cs | 7 ++++--- Source/MQTTnet/Client/MqttClient.cs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs index 44d50ec..158cc9a 100644 --- a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs +++ b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs @@ -5,12 +5,13 @@ namespace MQTTnet.Adapter { public class MqttConnectingFailedException : MqttCommunicationException { - public MqttConnectingFailedException(MqttClientConnectResultCode resultCode) + public MqttConnectingFailedException(MqttClientAuthenticateResult resultCode) : base($"Connecting with MQTT server failed ({resultCode.ToString()}).") { - ResultCode = resultCode; + Result = resultCode; } - public MqttClientConnectResultCode ResultCode { get; } + public MqttClientAuthenticateResult Result { get; } + public MqttClientConnectResultCode ResultCode => Result.ResultCode; } } diff --git a/Source/MQTTnet/Client/MqttClient.cs b/Source/MQTTnet/Client/MqttClient.cs index c9ef061..4d8269d 100644 --- a/Source/MQTTnet/Client/MqttClient.cs +++ b/Source/MQTTnet/Client/MqttClient.cs @@ -255,7 +255,7 @@ namespace MQTTnet.Client if (result.ResultCode != MqttClientConnectResultCode.Success) { - throw new MqttConnectingFailedException(result.ResultCode); + throw new MqttConnectingFailedException(result); } _logger.Verbose("Authenticated MQTT connection with server established.");