How to use the gmqtt.mqtt.utils.pack_utf8 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 / property.py View on Github external
def _dump_user_property(self, data, packet):
        packet.extend(struct.pack('!B', self.id))
        data1, data2 = data
        packet.extend(pack_utf8(data1))
        packet.extend(pack_utf8(data2))
github wialon / gmqtt / gmqtt / mqtt / property.py View on Github external
def _dump_user_property(self, data, packet):
        packet.extend(struct.pack('!B', self.id))
        data1, data2 = data
        packet.extend(pack_utf8(data1))
        packet.extend(pack_utf8(data2))
github wialon / gmqtt / gmqtt / mqtt / property.py View on Github external
def dumps(self, data):
        # packs property value into byte array
        packet = bytearray()
        if self.bytes_struct == 'u8':
            packet.extend(struct.pack('!B', self.id))
            packet.extend(pack_utf8(data))
            return packet
        elif self.bytes_struct == 'u8x2':
            if isinstance(data[0], str):
                self._dump_user_property(data, packet)
            else:
                for kv_pair in data:
                    self._dump_user_property(kv_pair, packet)
            return packet
        elif self.bytes_struct == 'b':
            packet.extend(struct.pack('!B', self.id))
            packet.extend(struct.pack('!H', len(data)))
            packet.extend(data)
            return packet
        elif self.bytes_struct == 'vbi':
            packet.extend(struct.pack('!B', self.id))
            packet.extend(pack_variable_byte_integer(data))