mqtt/pdu.py
def encode(self):
        '''
        Encode and store an UNSUBCRIBE control packet
        @raise e: C{ValueError} if any encoded topic string exceeds 65535 bytes
        '''
        header    = bytearray(1)
        payload   = bytearray()
        varHeader = encode16Int(self.msgId)
        header[0] = 0xA2    # packet with QoS=1
        for topic in self.topics:
            payload.extend(encodeString(topic)) # topic name
        header.extend(encodeLength(len(varHeader) + len(payload)))
        header.extend(varHeader)
        header.extend(payload)
        self.encoded = header
        return str(header) if PY2 else bytes(header)
def encode(self):
        '''
        Encode and store an UNSUBCRIBE control packet
        @raise e: C{ValueError} if any encoded topic string exceeds 65535 bytes
        '''
        header    = bytearray(1)
        payload   = bytearray()
        varHeader = encode16Int(self.msgId)
        header[0] = 0xA2    # packet with QoS=1
        for topic in self.topics:
            payload.extend(encodeString(topic)) # topic name
        header.extend(encodeLength(len(varHeader) + len(payload)))
        header.extend(varHeader)
        header.extend(payload)
        self.encoded = header
        return str(header) if PY2 else bytes(header)
Encode and store an UNSUBCRIBE control packet
        @raise e: C{ValueError} if any encoded topic string exceeds 65535 bytes