Exemplo n.º 1
0
 def test_to_stream(self):
     variable_header = PacketIdVariableHeader(10)
     payload = UnubscribePayload(['a/b', 'c/d'])
     publish = UnsubscribePacket(variable_header=variable_header,
                                 payload=payload)
     out = publish.to_bytes()
     self.assertEqual(out, b'\xa2\x0c\x00\n\x00\x03a/b\x00\x03c/d')
Exemplo n.º 2
0
 def test_to_stream(self):
     variable_header = PacketIdVariableHeader(10)
     payload = SubscribePayload([('a/b', QOS_1), ('c/d', QOS_2)])
     publish = SubscribePacket(variable_header=variable_header,
                               payload=payload)
     out = publish.to_bytes()
     self.assertEqual(out,
                      b'\x82\x0e\x00\x0a\x00\x03a/b\x01\x00\x03c/d\x02')
Exemplo n.º 3
0
 def test_to_stream(self):
     variable_header = PacketIdVariableHeader(10)
     payload = SubackPayload([
         SubackPayload.RETURN_CODE_00, SubackPayload.RETURN_CODE_01,
         SubackPayload.RETURN_CODE_02, SubackPayload.RETURN_CODE_80
     ])
     suback = SubackPacket(variable_header=variable_header, payload=payload)
     out = suback.to_bytes()
     self.assertEqual(out, b'\x90\x06\x00\x0a\x00\x01\x02\x80')
Exemplo n.º 4
0
 def test_to_stream(self):
     variable_header = PacketIdVariableHeader(10)
     payload = SubscribePayload([{
         'filter': 'a/b',
         'qos': 0x01
     }, {
         'filter': 'c/d',
         'qos': 0x02
     }])
     publish = SubscribePacket(variable_header=variable_header,
                               payload=payload)
     out = publish.to_bytes()
     self.assertEqual(out,
                      b'\x82\x0e\x00\x0a\x00\x03a/b\x01\x00\x03c/d\x02')
Exemplo n.º 5
0
 def build(cls, packet_id):
     variable_header = PacketIdVariableHeader(packet_id)
     return PubrelPacket(variable_header=variable_header)
Exemplo n.º 6
0
 def build(cls, topics, packet_id):
     v_header = PacketIdVariableHeader(packet_id)
     payload = UnubscribePayload(topics)
     return UnsubscribePacket(variable_header=v_header, payload=payload)
Exemplo n.º 7
0
 def build(cls, packet_id: int):
     v_header = PacketIdVariableHeader(packet_id)
     packet = PubcompPacket(variable_header=v_header)
     return packet
Exemplo n.º 8
0
 def test_to_stream(self):
     variable_header = PacketIdVariableHeader(10)
     publish = UnsubackPacket(variable_header=variable_header)
     out = publish.to_bytes()
     self.assertEqual(out, b'\xb0\x02\x00\x0a')