mqtt/pdu.py
def encode(self):
        '''
        Encode and store a CONNACK control packet. 
        '''
     
        header       = bytearray(1)
        varHeader    = bytearray(2)
        header[0]    = 0x20 
        varHeader[0] = self.session
        varHeader[1] = self.resultCode
        header.extend(encodeLength(len(varHeader)))
        header.extend(varHeader)
        self.encoded = header
        return str(header) if PY2 else bytes(header)
def encode(self):
        '''
        Encode and store a CONNACK control packet. 
        '''
     
        header       = bytearray(1)
        varHeader    = bytearray(2)
        header[0]    = 0x20 
        varHeader[0] = self.session
        varHeader[1] = self.resultCode
        header.extend(encodeLength(len(varHeader)))
        header.extend(varHeader)
        self.encoded = header
        return str(header) if PY2 else bytes(header)
Encode and store a CONNACK control packet.