def _handle_packet(self, packet):
    action = int.from_bytes(packet[:4], 'big')
    data = packet[4:]
    if (action == Actions.HANDLER_REPLY):
        reply_count = int.from_bytes(data[:2], 'big')
        data = data[2:]
        with self.batch_update():
            for i in range(reply_count):
                reply_len = int.from_bytes(data[:2], 'big')
                reply_id = int.from_bytes(data[2:6], 'big')
                reply_data = data[6:(6 + reply_len)]
                data_array = []
                while reply_data:
                    item_type = reply_data[0]
                    if (item_type == 0):
                        data_array.append(int.from_bytes(reply_data[1:9], 'big', signed=True))
                        reply_data = reply_data[9:]
                    elif (item_type == 1):
                        data_array.append(struct.unpack('>d', reply_data[1:9])[0])
                        reply_data = reply_data[9:]
                    else:
                        raise ValueError(f'Unknown item type {item_type}')
                if self.reply_handler:
                    self.reply_handler(reply_id, data_array)
    else:
        print('[app] Unknown packet type:', packet)
def _handle_packet(self, packet):
    action = int.from_bytes(packet[:4], 'big')
    data = packet[4:]
    if (action == Actions.HANDLER_REPLY):
        reply_count = int.from_bytes(data[:2], 'big')
        data = data[2:]
        with self.batch_update():
            for i in range(reply_count):
                reply_len = int.from_bytes(data[:2], 'big')
                reply_id = int.from_bytes(data[2:6], 'big')
                reply_data = data[6:(6 + reply_len)]
                data_array = []
                while reply_data:
                    item_type = reply_data[0]
                    if (item_type == 0):
                        data_array.append(int.from_bytes(reply_data[1:9], 'big', signed=True))
                        reply_data = reply_data[9:]
                    elif (item_type == 1):
                        data_array.append(struct.unpack('>d', reply_data[1:9])[0])
                        reply_data = reply_data[9:]
                    else:
                        raise ValueError(f'Unknown item type {item_type}')
                if self.reply_handler:
                    self.reply_handler(reply_id, data_array)
    else:
        print('[app] Unknown packet type:', packet)