Ejemplo 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')
Ejemplo 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")
Ejemplo 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')
Ejemplo n.º 4
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")
Ejemplo n.º 5
0
 def build(cls, topics, packet_id):
     v_header = PacketIdVariableHeader(packet_id)
     payload = UnubscribePayload(topics)
     return UnsubscribePacket(variable_header=v_header, payload=payload)
Ejemplo n.º 6
0
 def build(cls, packet_id: int):
     v_header = PacketIdVariableHeader(packet_id)
     packet = PubrecPacket(variable_header=v_header)
     return packet
Ejemplo n.º 7
0
 def build(cls, packet_id):
     variable_header = PacketIdVariableHeader(packet_id)
     return cls(variable_header=variable_header)