Search in sources :

Example 1 with DiskStorage

use of net.runelite.cache.fs.jagex.DiskStorage in project runelite by runelite.

the class ArchiveRequestHandler method handleRequest255.

private void handleRequest255(ChannelHandlerContext ctx, int index, int archiveId) throws IOException {
    logger.info("Client {} requests 255: index {}, archive {}", ctx.channel().remoteAddress(), index, archiveId);
    byte[] compressed;
    if (archiveId == 255) {
        // index 255 data, for each index:
        // 4 byte crc
        // 4 byte revision
        ByteBuf buffer = ctx.alloc().heapBuffer(store.getIndexes().size() * 8);
        for (Index i : store.getIndexes()) {
            buffer.writeInt(i.getCrc());
            buffer.writeInt(i.getRevision());
        }
        compressed = compress(CompressionType.NONE, Arrays.copyOf(buffer.array(), buffer.readableBytes()));
        buffer.release();
    } else {
        // Requires disk storage. Use packed index data from
        // store as its crc matches
        DiskStorage storage = (DiskStorage) store.getStorage();
        compressed = storage.readIndex(archiveId);
    }
    ArchiveResponsePacket response = new ArchiveResponsePacket();
    response.setIndex(index);
    response.setArchive(archiveId);
    response.setData(compressed);
    ctx.writeAndFlush(response);
}
Also used : Index(net.runelite.cache.fs.Index) ByteBuf(io.netty.buffer.ByteBuf) DiskStorage(net.runelite.cache.fs.jagex.DiskStorage) ArchiveResponsePacket(net.runelite.protocol.api.update.ArchiveResponsePacket)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 Index (net.runelite.cache.fs.Index)1 DiskStorage (net.runelite.cache.fs.jagex.DiskStorage)1 ArchiveResponsePacket (net.runelite.protocol.api.update.ArchiveResponsePacket)1