Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.slice()


            ByteBuf frame =  (ByteBuf) super.decode(ctx, buffer);
            if (frame == null) {
                return null;
            }
            int index = frame.indexOf(frame.readerIndex(), frame.writerIndex(), (byte) ' ');
            return new Cmd(frame.slice(frame.readerIndex(), index), frame.slice(index +1, frame.writerIndex()));
        }
    }

    public static final class CmdHandler extends SimpleChannelInboundHandler<Cmd> {
        @Override
View Full Code Here


        // Set the stream window size to zero.
        exhaustStreamWindow(STREAM_A);

        final ByteBuf data = dummyData(10, 0);
        try {
            send(STREAM_A, data.slice(), 0);
            verifyNoWrite(STREAM_A);

            // Verify that the entire frame was sent.
            controller.updateOutboundWindowSize(STREAM_A, 10);
            assertEquals(DEFAULT_WINDOW_SIZE - data.readableBytes(), window(CONNECTION_STREAM_ID));
View Full Code Here

            runInChannel(clientChannel, new Http2Runnable() {
                @Override
                public void run() {
                    frameWriter.writeHeaders(ctxClient(), 3, http2Headers, 0, false, newPromiseClient());
                    frameWriter
                    .writeData(ctxClient(), 3, content.slice(0, midPoint).retain(), 0, false, newPromiseClient());
                    frameWriter.writeData(ctxClient(), 3, content.slice(midPoint, text.length() - midPoint).retain(), 0,
                            true, newPromiseClient());
                    ctxClient().flush();
                }
            });
View Full Code Here

                @Override
                public void run() {
                    frameWriter.writeHeaders(ctxClient(), 3, http2Headers, 0, false, newPromiseClient());
                    frameWriter
                    .writeData(ctxClient(), 3, content.slice(0, midPoint).retain(), 0, false, newPromiseClient());
                    frameWriter.writeData(ctxClient(), 3, content.slice(midPoint, text.length() - midPoint).retain(), 0,
                            true, newPromiseClient());
                    ctxClient().flush();
                }
            });
            awaitRequests();
View Full Code Here

        encoderChannel.writeOutbound(Unpooled.wrappedBuffer(payload));
        ByteBuf compressedPayload = encoderChannel.readOutbound();

        BinaryWebSocketFrame compressedFrame = new BinaryWebSocketFrame(true,
                WebSocketExtension.RSV1 | WebSocketExtension.RSV3,
                compressedPayload.slice(0, compressedPayload.readableBytes() - 4));

        // execute
        decoderChannel.writeInbound(compressedFrame);
        BinaryWebSocketFrame uncompressedFrame = decoderChannel.readInbound();
View Full Code Here

    @Test
    public void frameShouldBeSentImmediately() throws Http2Exception {
        final ByteBuf data = dummyData(5, 5);
        try {
            send(STREAM_A, data.slice(0, 5), 5);
            verifyWrite(STREAM_A, data.slice(0, 5), 5);
            assertEquals(1, data.refCnt());
        } finally {
            manualSafeRelease(data);
        }
View Full Code Here

    @Test
    public void frameShouldBeSentImmediately() throws Http2Exception {
        final ByteBuf data = dummyData(5, 5);
        try {
            send(STREAM_A, data.slice(0, 5), 5);
            verifyWrite(STREAM_A, data.slice(0, 5), 5);
            assertEquals(1, data.refCnt());
        } finally {
            manualSafeRelease(data);
        }
    }
View Full Code Here

        final ByteBuf data = dummyData(5, 0);
        try {
            send(STREAM_A, data.copy(), 5);

            verifyWrite(STREAM_A, data.slice(0, 3), 0);
            verifyWrite(STREAM_A, data.slice(3, 2), 1);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 3);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 1);
        } finally {
            manualSafeRelease(data);
View Full Code Here

        final ByteBuf data = dummyData(5, 0);
        try {
            send(STREAM_A, data.copy(), 5);

            verifyWrite(STREAM_A, data.slice(0, 3), 0);
            verifyWrite(STREAM_A, data.slice(3, 2), 1);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 3);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 1);
        } finally {
            manualSafeRelease(data);
        }
View Full Code Here

    public void stalledStreamShouldQueueFrame() throws Http2Exception {
        controller.initialOutboundWindowSize(0);

        final ByteBuf data = dummyData(10, 5);
        try {
            send(STREAM_A, data.slice(0, 10), 5);
            verifyNoWrite(STREAM_A);
            assertEquals(1, data.refCnt());
        } finally {
            manualSafeRelease(data);
        }
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.