Browse Source

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.
release/3.x.x
Jim Schaad 5 years ago
parent
commit
9c378fb088
2 changed files with 5 additions and 4 deletions
  1. +4
    -3
      Source/MQTTnet/Adapter/MqttConnectingFailedException.cs
  2. +1
    -1
      Source/MQTTnet/Client/MqttClient.cs

+ 4
- 3
Source/MQTTnet/Adapter/MqttConnectingFailedException.cs View File

@@ -5,12 +5,13 @@ namespace MQTTnet.Adapter
{ {
public class MqttConnectingFailedException : MqttCommunicationException public class MqttConnectingFailedException : MqttCommunicationException
{ {
public MqttConnectingFailedException(MqttClientConnectResultCode resultCode)
public MqttConnectingFailedException(MqttClientAuthenticateResult resultCode)
: base($"Connecting with MQTT server failed ({resultCode.ToString()}).") : 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;
} }
} }

+ 1
- 1
Source/MQTTnet/Client/MqttClient.cs View File

@@ -255,7 +255,7 @@ namespace MQTTnet.Client


if (result.ResultCode != MqttClientConnectResultCode.Success) if (result.ResultCode != MqttClientConnectResultCode.Success)
{ {
throw new MqttConnectingFailedException(result.ResultCode);
throw new MqttConnectingFailedException(result);
} }


_logger.Verbose("Authenticated MQTT connection with server established."); _logger.Verbose("Authenticated MQTT connection with server established.");


Loading…
Cancel
Save