Exemplo n.º 1
0
    def handle_publish(self, publish_packet: PublishPacket):
        packet_id = publish_packet.variable_header.packet_id
        qos = publish_packet.qos

        incoming_message = IncomingApplicationMessage(packet_id, publish_packet.topic_name, qos, publish_packet.data, publish_packet.retain_flag)
        incoming_message.publish_packet = publish_packet
        yield from self._handle_message_flow(incoming_message)
        self.logger.debug("Message queue size: %d" % self.session.delivered_message_queue.qsize())
Exemplo n.º 2
0
    def handle_publish(self, publish_packet: PublishPacket):
        packet_id = publish_packet.variable_header.packet_id
        qos = publish_packet.qos

        incoming_message = IncomingApplicationMessage(packet_id, publish_packet.topic_name, qos, publish_packet.data, publish_packet.retain_flag)
        incoming_message.publish_packet = publish_packet
        yield from self._handle_message_flow(incoming_message)
        self.logger.debug("Message queue size: %d" % self.session.delivered_message_queue.qsize())
 async def mock_deliver_message():
     if deliver_event.is_set():
         # simulate some i/o blocking, otherwise the deliver method is called nons-top by __run_on_message loop
         # and takes all cpu, not giving a chance to other tasks
         await asyncio.sleep(0.2)
     else:
         deliver_event.set()
     in_message = None
     #the very first deliver_message invocation is only used for verification that __run_on_message is running,
     # so in_message=None in this case
     if deliver_controls[1] < deliver_controls[0] and deliver_controls[
             0] > 0:
         message_topic = topic if topic_ns is None else f'{topic_ns}{topic}'
         in_message = IncomingApplicationMessage('packet_id', message_topic,
                                                 QOS_0,
                                                 message.encode('utf-8'),
                                                 False)
         in_message.publish_packet = in_message.build_publish_packet()
     deliver_controls[1] += 1
     return in_message
Exemplo n.º 4
0
    async def handle_publish(self, publish_packet: PublishPacket):
        try:
            packet_id = publish_packet.variable_header.packet_id
            qos = publish_packet.qos

            incoming_message = IncomingApplicationMessage(
                packet_id, publish_packet.topic_name, qos, publish_packet.data,
                publish_packet.retain_flag)
            incoming_message.publish_packet = publish_packet
            if incoming_message.qos == QOS_0:
                await self._handle_message_flow(incoming_message)
            else:
                await self._reader_task.spawn(self._handle_message_flow,
                                              incoming_message)

            if self.session is not None:
                self.logger.debug(
                    "Message queue size: %d",
                    self.session._delivered_message_queue.qsize())
        except CancelledError:
            pass