def start_packet(self): try: if len(self._stream) > 2 and self.payload_size is None: packet_header = packets.start_packet().parse(self._stream) self.id = packet_header.id self.payload_size = abs(packet_header.payload_size) if packet_header.payload_size < 0: self.compressed = True else: self.compressed = False self.header_length = 1 + len(packets.SignedVLQ("").build(packet_header.payload_size)) self.packet_size = self.payload_size + self.header_length return True except RuntimeError: self.logger.error("Unknown error in start_packet.") return False
def start_packet(self): try: if len(self._stream) > 2 and self.payload_size is None: packet_header = packets.start_packet().parse(self._stream) self.id = packet_header.id self.payload_size = abs(packet_header.payload_size) if packet_header.payload_size < 0: self.compressed = True else: self.compressed = False self.header_length = 1 + len(packets.SignedVLQ("").build(packet_header.payload_size)) self.packet_size = self.payload_size + self.header_length return True except: self.logger.exception("Unknown error in start_packet.") return False