Package io.netty.buffer

Examples of io.netty.buffer.CompositeByteBuf.writerIndex()


    private static ByteBuf readUncompressed(EmbeddedChannel channel) throws Exception {
        CompositeByteBuf uncompressed = Unpooled.compositeBuffer();
        ByteBuf msg;
        while ((msg = channel.readInbound()) != null) {
            uncompressed.addComponent(msg);
            uncompressed.writerIndex(uncompressed.writerIndex() + msg.readableBytes());
        }

        return uncompressed;
    }
View Full Code Here


    private static ByteBuf readUncompressed(EmbeddedChannel channel) throws Exception {
        CompositeByteBuf uncompressed = Unpooled.compositeBuffer();
        ByteBuf msg;
        while ((msg = channel.readInbound()) != null) {
            uncompressed.addComponent(msg);
            uncompressed.writerIndex(uncompressed.writerIndex() + msg.readableBytes());
        }

        return uncompressed;
    }
View Full Code Here

            encoder.writeOutbound(in.copy());
            encoder.finish();
            final CompositeByteBuf compressed = Unpooled.compositeBuffer();
            while ((msg = encoder.readOutbound()) != null) {
                compressed.addComponent(msg);
                compressed.writerIndex(compressed.writerIndex() + msg.readableBytes());
            }
            assertThat(compressed, is(notNullValue()));

            decoder.writeInbound(compressed.retain());
            assertFalse(compressed.isReadable());
View Full Code Here

            encoder.writeOutbound(in.copy());
            encoder.finish();
            final CompositeByteBuf compressed = Unpooled.compositeBuffer();
            while ((msg = encoder.readOutbound()) != null) {
                compressed.addComponent(msg);
                compressed.writerIndex(compressed.writerIndex() + msg.readableBytes());
            }
            assertThat(compressed, is(notNullValue()));

            decoder.writeInbound(compressed.retain());
            assertFalse(compressed.isReadable());
View Full Code Here

            decoder.writeInbound(compressed.retain());
            assertFalse(compressed.isReadable());
            final CompositeByteBuf decompressed = Unpooled.compositeBuffer();
            while ((msg = decoder.readInbound()) != null) {
                decompressed.addComponent(msg);
                decompressed.writerIndex(decompressed.writerIndex() + msg.readableBytes());
            }
            assertEquals(in, decompressed);

            compressed.release();
            decompressed.release();
View Full Code Here

            decoder.writeInbound(compressed.retain());
            assertFalse(compressed.isReadable());
            final CompositeByteBuf decompressed = Unpooled.compositeBuffer();
            while ((msg = decoder.readInbound()) != null) {
                decompressed.addComponent(msg);
                decompressed.writerIndex(decompressed.writerIndex() + msg.readableBytes());
            }
            assertEquals(in, decompressed);

            compressed.release();
            decompressed.release();
View Full Code Here

    private static byte[] uncompress(EmbeddedChannel channel, int originalLength) throws Exception {
        CompositeByteBuf out = Unpooled.compositeBuffer();
        ByteBuf msg;
        while ((msg = channel.readOutbound()) != null) {
            out.addComponent(msg);
            out.writerIndex(out.writerIndex() + msg.readableBytes());
        }

        byte[] compressed = new byte[out.readableBytes()];
        out.readBytes(compressed);
        out.release();
View Full Code Here

    private static byte[] uncompress(EmbeddedChannel channel, int originalLength) throws Exception {
        CompositeByteBuf out = Unpooled.compositeBuffer();
        ByteBuf msg;
        while ((msg = channel.readOutbound()) != null) {
            out.addComponent(msg);
            out.writerIndex(out.writerIndex() + msg.readableBytes());
        }

        byte[] compressed = new byte[out.readableBytes()];
        out.readBytes(compressed);
        out.release();
View Full Code Here

    private static byte[] uncompress(EmbeddedChannel channel, int length) throws Exception {
        CompositeByteBuf out = Unpooled.compositeBuffer();
        ByteBuf msg;
        while ((msg = channel.readOutbound()) != null) {
            out.addComponent(msg);
            out.writerIndex(out.writerIndex() + msg.readableBytes());
        }

        byte[] compressed = new byte[out.readableBytes()];
        out.readBytes(compressed);
        out.release();
View Full Code Here

    private static byte[] uncompress(EmbeddedChannel channel, int length) throws Exception {
        CompositeByteBuf out = Unpooled.compositeBuffer();
        ByteBuf msg;
        while ((msg = channel.readOutbound()) != null) {
            out.addComponent(msg);
            out.writerIndex(out.writerIndex() + msg.readableBytes());
        }

        byte[] compressed = new byte[out.readableBytes()];
        out.readBytes(compressed);
        out.release();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.