fix reason codes
This commit is contained in:
parent
9406bc1fd1
commit
23e72feab7
|
@ -407,13 +407,14 @@ connack({?RC_SUCCESS, SP, PState}) ->
|
|||
deliver({connack, ?RC_SUCCESS, sp(SP)}, update_mountpoint(PState));
|
||||
|
||||
connack({ReasonCode, PState = #pstate{proto_ver = ProtoVer}}) ->
|
||||
emqx_hooks:run('client.connected', [credentials(PState), ?RC_SUCCESS, attrs(PState)]),
|
||||
_ = deliver({connack, if ProtoVer =:= ?MQTT_PROTO_V5 ->
|
||||
ReasonCode;
|
||||
true ->
|
||||
emqx_reason_codes:compat(connack, ReasonCode)
|
||||
end}, PState),
|
||||
{error, emqx_reason_codes:name(ReasonCode, ProtoVer), PState}.
|
||||
emqx_hooks:run('client.connected', [credentials(PState), ReasonCode, attrs(PState)]),
|
||||
ReasonCode1 = if ProtoVer =:= ?MQTT_PROTO_V5 ->
|
||||
ReasonCode;
|
||||
true ->
|
||||
emqx_reason_codes:compat(connack, ReasonCode)
|
||||
end,
|
||||
_ = deliver({connack, ReasonCode1}, PState),
|
||||
{error, emqx_reason_codes:name(ReasonCode1, ProtoVer), PState}.
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% Publish Message -> Broker
|
||||
|
|
|
@ -27,7 +27,8 @@ name(1, _Ver) -> unacceptable_protocol_version;
|
|||
name(2, _Ver) -> client_identifier_not_valid;
|
||||
name(3, _Ver) -> server_unavaliable;
|
||||
name(4, _Ver) -> malformed_username_or_password;
|
||||
name(5, _Ver) -> unauthorized_client.
|
||||
name(5, _Ver) -> unauthorized_client;
|
||||
name(I, _Ver) -> list_to_atom("unkown_connack" ++ integer_to_list(I)).
|
||||
|
||||
name(16#00) -> success;
|
||||
name(16#01) -> granted_qos1;
|
||||
|
@ -139,4 +140,3 @@ compat(connack, 16#9F) -> ?CONNACK_SERVER;
|
|||
|
||||
compat(suback, Code) when Code =< ?QOS2 -> Code;
|
||||
compat(suback, Code) when Code > 16#80 -> 16#80.
|
||||
|
||||
|
|
Loading…
Reference in New Issue