Merge pull request #1783 from tigercl/emqx30

Change in CONNECT packet
This commit is contained in:
Feng Lee 2018-09-04 14:14:50 +08:00 committed by GitHub
commit 9f8461c67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -120,19 +120,17 @@ wrap(Header, Rest) ->
parse_packet(#mqtt_packet_header{type = ?CONNECT}, FrameBin, _Options) -> parse_packet(#mqtt_packet_header{type = ?CONNECT}, FrameBin, _Options) ->
{ProtoName, Rest} = parse_utf8_string(FrameBin), {ProtoName, Rest} = parse_utf8_string(FrameBin),
<<BridgeTag:4, ProtoVer:4, Rest1/binary>> = Rest, <<BridgeTag:4, ProtoVer:4, Rest1/binary>> = Rest,
% Note: Crash when reserved flag doesn't equal to 0, there is no strict compliance with the MQTT5.0.
<<UsernameFlag : 1, <<UsernameFlag : 1,
PasswordFlag : 1, PasswordFlag : 1,
WillRetain : 1, WillRetain : 1,
WillQoS : 2, WillQoS : 2,
WillFlag : 1, WillFlag : 1,
CleanStart : 1, CleanStart : 1,
_Reserved : 1, 0 : 0,
KeepAlive : 16/big, KeepAlive : 16/big,
Rest2/binary>> = Rest1, Rest2/binary>> = Rest1,
case protocol_approved(ProtoVer, ProtoName) of
true -> ok;
false -> error(protocol_name_unapproved)
end,
{Properties, Rest3} = parse_properties(Rest2, ProtoVer), {Properties, Rest3} = parse_properties(Rest2, ProtoVer),
{ClientId, Rest4} = parse_utf8_string(Rest3), {ClientId, Rest4} = parse_utf8_string(Rest3),
ConnPacket = #mqtt_packet_connect{proto_name = ProtoName, ConnPacket = #mqtt_packet_connect{proto_name = ProtoName,