How to use the gmqtt.mqtt.utils.run_coroutine_or_function function in gmqtt

To help you get started, we’ve selected a few gmqtt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wialon / gmqtt / gmqtt / mqtt / handler.py View on Github external
def _handle_qos_2_publish_packet(self, mid, packet, print_topic, properties):
        if self._optimistic_acknowledgement:
            self._send_pubrec(mid)
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 2, properties)
        else:
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 2, properties,
                                      callback=partial(self.__handle_publish_callback, qos=2, mid=mid))
github wialon / gmqtt / gmqtt / mqtt / handler.py View on Github external
def _handle_qos_1_publish_packet(self, mid, packet, print_topic, properties):
        if self._optimistic_acknowledgement:
            self._send_puback(mid)
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 1, properties)
        else:
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 1, properties,
                                      callback=partial(self.__handle_publish_callback, qos=1, mid=mid))
github wialon / gmqtt / gmqtt / mqtt / handler.py View on Github external
def _handle_qos_1_publish_packet(self, mid, packet, print_topic, properties):
        if self._optimistic_acknowledgement:
            self._send_puback(mid)
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 1, properties)
        else:
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 1, properties,
                                      callback=partial(self.__handle_publish_callback, qos=1, mid=mid))
github wialon / gmqtt / gmqtt / mqtt / handler.py View on Github external
if qos > 0:
            pack_format = "!H" + str(len(packet) - 2) + 's'
            (mid, packet) = struct.unpack(pack_format, packet)
        else:
            mid = None

        properties, packet = self._parse_properties(packet)
        properties['dup'] = dup
        properties['retain'] = retain

        if packet is None:
            logger.critical('[INVALID MESSAGE] skipping: {}'.format(raw_packet))
            return

        if qos == 0:
            run_coroutine_or_function(self.on_message, self, print_topic, packet, qos, properties)
        elif qos == 1:
            self._handle_qos_1_publish_packet(mid, packet, print_topic, properties)
        elif qos == 2:
            self._handle_qos_2_publish_packet(mid, packet, print_topic, properties)
        self._id_generator.free_id(mid)
github wialon / gmqtt / gmqtt / mqtt / handler.py View on Github external
def _handle_qos_2_publish_packet(self, mid, packet, print_topic, properties):
        if self._optimistic_acknowledgement:
            self._send_pubrec(mid)
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 2, properties)
        else:
            run_coroutine_or_function(self.on_message, self, print_topic, packet, 2, properties,
                                      callback=partial(self.__handle_publish_callback, qos=2, mid=mid))