Make DISCONNECT packet with reason code 0x00 when this packet doesn't have payload
This commit is contained in:
parent
42b3c9b4d6
commit
917eb8e29f
|
@ -76,6 +76,9 @@ parse_remaining_len(_Bin, _Header, _Multiplier, Length,
|
||||||
error(mqtt_frame_too_large);
|
error(mqtt_frame_too_large);
|
||||||
parse_remaining_len(<<>>, Header, Multiplier, Length, Options) ->
|
parse_remaining_len(<<>>, Header, Multiplier, Length, Options) ->
|
||||||
{more, fun(Bin) -> parse_remaining_len(Bin, Header, Multiplier, Length, Options) end};
|
{more, fun(Bin) -> parse_remaining_len(Bin, Header, Multiplier, Length, Options) end};
|
||||||
|
%% Match DISCONNECT without payload
|
||||||
|
parse_remaining_len(<<0:8, Rest/binary>>, Header = #mqtt_packet_header{type = ?DISCONNECT}, 1, 0, _Options) ->
|
||||||
|
wrap(Header, #mqtt_packet_disconnect{reason_code = ?RC_SUCCESS}, Rest);
|
||||||
%% Match PINGREQ.
|
%% Match PINGREQ.
|
||||||
parse_remaining_len(<<0:8, Rest/binary>>, Header, 1, 0, Options) ->
|
parse_remaining_len(<<0:8, Rest/binary>>, Header, 1, 0, Options) ->
|
||||||
parse_frame(Rest, Header, 0, Options);
|
parse_frame(Rest, Header, 0, Options);
|
||||||
|
|
|
@ -399,15 +399,11 @@ process_packet(?UNSUBSCRIBE_PACKET(PacketId, Properties, RawTopicFilters),
|
||||||
process_packet(?PACKET(?PINGREQ), PState) ->
|
process_packet(?PACKET(?PINGREQ), PState) ->
|
||||||
send(?PACKET(?PINGRESP), PState);
|
send(?PACKET(?PINGRESP), PState);
|
||||||
|
|
||||||
process_packet(?DISCONNECT_PACKET(16#00), PState) ->
|
process_packet(?DISCONNECT_PACKET(?RC_SUCCESS), PState) ->
|
||||||
%% Clean willmsg
|
%% Clean willmsg
|
||||||
{stop, normal, PState#pstate{will_msg = undefined}};
|
{stop, normal, PState#pstate{will_msg = undefined}};
|
||||||
process_packet(?DISCONNECT_PACKET(_), PState) ->
|
process_packet(?DISCONNECT_PACKET(_), PState) ->
|
||||||
{stop, normal, PState};
|
{stop, normal, PState}.
|
||||||
process_packet(Packet = ?PACKET(?DISCONNECT), PState) ->
|
|
||||||
if Packet#mqtt_packet.variable =:= undefined ->
|
|
||||||
{stop, normal, PState#pstate{will_msg = undefined}}
|
|
||||||
end.
|
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% ConnAck --> Client
|
%% ConnAck --> Client
|
||||||
|
|
Loading…
Reference in New Issue