def to_bytes(self, fixed_header: MQTTFixedHeader, variable_header: MQTTVariableHeader): out = b'' for topic in self.topics: out += encode_string(topic[0]) out += int_to_bytes(topic[1], 1) return out
def to_bytes(self): out = bytearray() # Protocol name out.extend(encode_string(self.proto_name)) # Protocol level out.append(self.proto_level) # flags out.append(self.flags) # keep alive out.extend(int_to_bytes(self.keep_alive, 2)) return out
def to_bytes(self, fixed_header: MQTTFixedHeader, variable_header: MQTTVariableHeader): out = b'' for return_code in self.return_codes: out += int_to_bytes(return_code, 1) return out
def to_bytes(self): out = bytearray() out.extend(encode_string(self.topic_name)) if self.packet_id is not None: out.extend(int_to_bytes(self.packet_id, 2)) return out
def to_bytes(self): out = b"" out += int_to_bytes(self.packet_id, 2) return out