Пример #1
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
         ])
     publish = SubackPacket(variable_header=variable_header, payload=payload)
     out = publish.to_bytes()
     self.assertEqual(out, b'\x90\x06\x00\x0a\x00\x01\x02\x80')
Пример #2
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')
Пример #3
0
 def test_from_stream(self):
     data = b'\x90\x06\x00\x0a\x00\x01\x02\x80'
     stream = BufferReader(data)
     message = self.loop.run_until_complete(SubackPacket.from_stream(stream))
     self.assertEqual(message.payload.return_codes[0], SubackPayload.RETURN_CODE_00)
     self.assertEqual(message.payload.return_codes[1], SubackPayload.RETURN_CODE_01)
     self.assertEqual(message.payload.return_codes[2], SubackPayload.RETURN_CODE_02)
     self.assertEqual(message.payload.return_codes[3], SubackPayload.RETURN_CODE_80)
Пример #4
0
 def test_from_stream(self):
     data = b'\x90\x06\x00\x0a\x00\x01\x02\x80'
     stream = BufferReader(data)
     message = self.loop.run_until_complete(
         SubackPacket.from_stream(stream))
     self.assertEqual(message.payload.return_codes[0],
                      SubackPayload.RETURN_CODE_00)
     self.assertEqual(message.payload.return_codes[1],
                      SubackPayload.RETURN_CODE_01)
     self.assertEqual(message.payload.return_codes[2],
                      SubackPayload.RETURN_CODE_02)
     self.assertEqual(message.payload.return_codes[3],
                      SubackPayload.RETURN_CODE_80)
Пример #5
0
 async def mqtt_acknowledge_subscription(self, packet_id, return_codes):
     suback = SubackPacket.build(packet_id, return_codes)
     await self._send_packet(suback)
Пример #6
0
 def mqtt_acknowledge_subscription(self, packet_id, return_codes):
     suback = SubackPacket.build(packet_id, return_codes)
     yield from self._send_packet(suback)
Пример #7
0
 def mqtt_acknowledge_subscription(self, packet_id, return_codes):
     suback = SubackPacket.build(packet_id, return_codes)
     yield from self.outgoing_queue.put(suback)