Search in sources :

Example 1 with GZIPStream

use of org.rx.io.GZIPStream in project rxlib by RockyLOMO.

the class Udp2rawHandler method zip.

private void zip(ByteBuf outBuf, ByteBuf inBuf) {
    if (inBuf.readableBytes() < gzipMinLength) {
        outBuf.writeByte(1);
        outBuf.writeBytes(inBuf);
        return;
    }
    outBuf.writeByte(2);
    int w = outBuf.writerIndex();
    int unzipLen = inBuf.readableBytes();
    try (GZIPStream stream = new GZIPStream(new MemoryStream(outBuf, true), true)) {
        stream.write(inBuf);
    }
    outBuf.readerIndex(0);
    log.info("UDP2RAW ZIP {} => {}", unzipLen, outBuf.writerIndex() - w);
}
Also used : GZIPStream(org.rx.io.GZIPStream) MemoryStream(org.rx.io.MemoryStream) AuthenticEndpoint(org.rx.net.AuthenticEndpoint) UnresolvedEndpoint(org.rx.net.support.UnresolvedEndpoint)

Aggregations

GZIPStream (org.rx.io.GZIPStream)1 MemoryStream (org.rx.io.MemoryStream)1 AuthenticEndpoint (org.rx.net.AuthenticEndpoint)1 UnresolvedEndpoint (org.rx.net.support.UnresolvedEndpoint)1