Package io.netty.buffer

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


                    break;
                }

                if (m instanceof ByteBuf) {
                    ByteBuf src = (ByteBuf) m;
                    byteSink.writeBytes(src, src.readerIndex(), src.readableBytes());
                } else {
                    logger.debug(
                            "Discarded outbound message {} that reached at the head of the pipeline. " +
                                    "Please check your pipeline configuration.", m);
                    discardedMessages ++;
View Full Code Here


    protected void encode(ChannelHandlerContext ctx, WebSocketFrame msg, ByteBuf out) throws Exception {
        if (msg instanceof TextWebSocketFrame) {
            // Text frame
            ByteBuf data = msg.data();
            out.writeByte((byte) 0x00);
            out.writeBytes(data, data.readerIndex(), data.readableBytes());
            out.writeByte((byte) 0xFF);
        } else if (msg instanceof CloseWebSocketFrame) {
            // Close frame
            out.writeByte((byte) 0xFF);
            out.writeByte((byte) 0x00);
View Full Code Here

                out.writeByte(b3 | 0x80);
                out.writeByte(b4);
            }

            // Encode binary data.
            out.writeBytes(data, data.readerIndex(), dataLen);
        }
    }
}
View Full Code Here

    }

    @Override
    public final void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception {
        ByteBuf in = ctx.inboundByteBuffer();
        final int oldReaderIndex = in.readerIndex();
        discardInboundReadBytes0(ctx);
        final int newReaderIndex = in.readerIndex();
        checkpoint -= oldReaderIndex - newReaderIndex;
    }
View Full Code Here

    @Override
    public final void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception {
        ByteBuf in = ctx.inboundByteBuffer();
        final int oldReaderIndex = in.readerIndex();
        discardInboundReadBytes0(ctx);
        final int newReaderIndex = in.readerIndex();
        checkpoint -= oldReaderIndex - newReaderIndex;
    }

    protected void discardInboundReadBytes0(ChannelHandlerContext ctx) throws Exception {
        super.discardInboundReadBytes(ctx);
View Full Code Here

        ByteBuf in = cumulation;
        MessageBuf<Object> out = ctx.nextInboundMessageBuffer();
        boolean decoded = false;
        while (in.isReadable()) {
            try {
                int oldReaderIndex = checkpoint = in.readerIndex();
                Object result = null;
                S oldState = state;
                try {
                    result = decode(ctx, replayable);
                    if (result == null) {
View Full Code Here

                Object result = null;
                S oldState = state;
                try {
                    result = decode(ctx, replayable);
                    if (result == null) {
                        if (oldReaderIndex == in.readerIndex() && oldState == state) {
                            throw new IllegalStateException(
                                    "null cannot be returned if no data is consumed and state didn't change.");
                        } else {
                            // Previous data has been discarded or caused state transition.
                            // Probably it is reading on.
View Full Code Here

                } catch (Signal replay) {
                    replay.expect(REPLAY);
                    // Return to the checkpoint (or oldPosition) and retry.
                    int checkpoint = this.checkpoint;
                    if (checkpoint >= 0) {
                        in.readerIndex(checkpoint);
                    } else {
                        // Called by cleanup() - no need to maintain the readerIndex
                        // anymore because the buffer has been released already.
                    }
                }
View Full Code Here

                    // Let us wait for the next notification.
                    break;
                }
                wasNull = false;

                if (oldReaderIndex == in.readerIndex() && oldState == state) {
                    throw new IllegalStateException(
                            "decode() method must consume at least one byte " +
                            "if it returned a decoded message (caused by: " +
                            getClass() + ')');
                }
View Full Code Here

            ByteBuf content = chunk.data();
            int contentLength = content.readableBytes();

            if (state == ST_CONTENT_NON_CHUNK) {
                if (contentLength > 0) {
                    out.writeBytes(content, content.readerIndex(), content.readableBytes());
                }

                if (chunk instanceof LastHttpContent) {
                    state = ST_INIT;
                }
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.