forked from dotnet/MQTTnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose more properties to connection validator context.
- Loading branch information
Showing
12 changed files
with
302 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using MQTTnet.Exceptions; | ||
|
||
namespace MQTTnet.Protocol | ||
{ | ||
public class MqttConnectReasonCodeConverter | ||
{ | ||
public MqttConnectReturnCode ToConnectReturnCode(MqttConnectReasonCode reasonCode) | ||
{ | ||
switch (reasonCode) | ||
{ | ||
case MqttConnectReasonCode.Success: | ||
{ | ||
return MqttConnectReturnCode.ConnectionAccepted; | ||
} | ||
|
||
case MqttConnectReasonCode.NotAuthorized: | ||
{ | ||
return MqttConnectReturnCode.ConnectionRefusedNotAuthorized; | ||
} | ||
|
||
case MqttConnectReasonCode.BadUserNameOrPassword: | ||
{ | ||
return MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword; | ||
} | ||
|
||
case MqttConnectReasonCode.ClientIdentifierNotValid: | ||
{ | ||
return MqttConnectReturnCode.ConnectionRefusedIdentifierRejected; | ||
} | ||
|
||
case MqttConnectReasonCode.UnsupportedProtocolVersion: | ||
{ | ||
return MqttConnectReturnCode.ConnectionRefusedUnacceptableProtocolVersion; | ||
} | ||
|
||
case MqttConnectReasonCode.ServerUnavailable: | ||
case MqttConnectReasonCode.ServerBusy: | ||
case MqttConnectReasonCode.ServerMoved: | ||
{ | ||
return MqttConnectReturnCode.ConnectionRefusedServerUnavailable; | ||
} | ||
|
||
default: | ||
{ | ||
throw new MqttProtocolViolationException("Unable to convert connect reason code (MQTTv5) to return code (MQTTv3)."); | ||
} | ||
} | ||
} | ||
|
||
public MqttConnectReasonCode ToConnectReasonCode(MqttConnectReturnCode returnCode) | ||
{ | ||
switch (returnCode) | ||
{ | ||
case MqttConnectReturnCode.ConnectionAccepted: | ||
{ | ||
return MqttConnectReasonCode.Success; | ||
} | ||
|
||
case MqttConnectReturnCode.ConnectionRefusedUnacceptableProtocolVersion: | ||
{ | ||
return MqttConnectReasonCode.UnsupportedProtocolVersion; | ||
} | ||
|
||
case MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword: | ||
{ | ||
return MqttConnectReasonCode.BadUserNameOrPassword; | ||
} | ||
|
||
case MqttConnectReturnCode.ConnectionRefusedIdentifierRejected: | ||
{ | ||
return MqttConnectReasonCode.ClientIdentifierNotValid; | ||
} | ||
|
||
case MqttConnectReturnCode.ConnectionRefusedServerUnavailable: | ||
{ | ||
return MqttConnectReasonCode.ServerUnavailable; | ||
} | ||
|
||
case MqttConnectReturnCode.ConnectionRefusedNotAuthorized: | ||
{ | ||
return MqttConnectReasonCode.NotAuthorized; | ||
} | ||
|
||
default: | ||
{ | ||
throw new MqttProtocolViolationException("Unable to convert connect reason code (MQTTv5) to return code (MQTTv3)."); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.