File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
src/mqtt/protocol/packets Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -43,20 +43,18 @@ module MQTT
4343
4444 protocol_len = io.read_int
4545 protocol = io.read_string(protocol_len)
46+ version = io.read_byte
4647
4748 # MQIsdp is for MQTT 3.1, MQTT is for MQTT 3.1.1
48- if protocol == " MQTT"
49- decode_assert protocol_len == 4 , " invalid protocol length for MQTT 3.1.1: #{ protocol_len } "
50- elsif protocol == " MQIsdp"
51- decode_assert protocol_len == 6 , " invalid protocol length for MQTT 3.1: #{ protocol_len } "
49+ case protocol
50+ when " MQTT"
51+ decode_assert version == 0x04 , Error ::UnacceptableProtocolVersion
52+ when " MQIsdp"
53+ decode_assert version == 0x03 , Error ::UnacceptableProtocolVersion
5254 else
53- decode_assert false , " invalid protocol: #{ protocol.inspect } "
55+ raise Error :: UnacceptableProtocolVersion .new( " invalid protocol: #{ protocol.inspect } " )
5456 end
5557
56- version = io.read_byte
57- decode_assert version == 0x04 || version == 0x03 , Error ::UnacceptableProtocolVersion
58- # @version will be set when we create a new instance at the end of this method
59-
6058 connect_flags = io.read_byte
6159 decode_assert connect_flags.bit(0 ) == 0 , " reserved connect flag set"
6260 clean_session = connect_flags.bit(1 ) == 1
You can’t perform that action at this time.
0 commit comments