Package io.netty.buffer

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


        }

        ByteBuf binaryData = Unpooled.buffer(2 + reasonBytes.length);
        binaryData.writeShort(statusCode);
        if (reasonBytes.length > 0) {
            binaryData.writeBytes(reasonBytes);
        }

        binaryData.readerIndex(0);
        return binaryData;
    }
View Full Code Here


            if (forwardPrev.hasOutboundByteBuffer()) {
                forwardPrevBuf = forwardPrev.outboundByteBuffer();
            } else {
                forwardPrevBuf = forwardPrev.nextOutboundByteBuffer();
            }
            forwardPrevBuf.writeBytes(outboundByteBuffer());
            flush = true;
        }
        if (hasOutboundMessageBuffer() && !outboundMessageBuffer().isEmpty()) {
            MessageBuf<Object> forwardPrevBuf;
            if (forwardPrev.hasOutboundMessageBuffer()) {
View Full Code Here

            if (forwardNext.hasInboundByteBuffer()) {
                forwardNextBuf = forwardNext.inboundByteBuffer();
            } else {
                forwardNextBuf = forwardNext.nextInboundByteBuffer();
            }
            forwardNextBuf.writeBytes(inboundByteBuffer());
            inboundBufferUpdated = true;
        }
        if (hasInboundMessageBuffer() && !inboundMessageBuffer().isEmpty()) {
            MessageBuf<Object> forwardNextBuf;
            if (forwardNext.hasInboundMessageBuffer()) {
View Full Code Here

    }

    @Override
    public void inboundBufferUpdated(final ChannelHandlerContext ctx, ByteBuf in) throws Exception {
        ByteBuf out = outboundChannel.outboundByteBuffer();
        out.writeBytes(in);
        if (outboundChannel.isActive()) {
            outboundChannel.flush().addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (future.isSuccess()) {
View Full Code Here

        final int maximumMessageSize = config.getReceiveBufferSize();

        final ByteBuf byteBuf = config.getAllocator().directBuffer(
                maximumMessageSize);

        final int receivedMessageSize = byteBuf.writeBytes(javaChannel(),
                maximumMessageSize);

        if (receivedMessageSize <= 0) {
            byteBuf.release();
            return 0;
View Full Code Here

    public void inboundBufferUpdated(final ChannelHandlerContext ctx,
            final ByteBuf in) {
        meter.mark(in.readableBytes());
        final ByteBuf out = ctx.nextOutboundByteBuffer();
        out.discardReadBytes();
        out.writeBytes(in);
        ctx.flush();
    }

    @Override
    public void exceptionCaught(final ChannelHandlerContext ctx,
View Full Code Here

    @Override
    public void inboundBufferUpdated(final ChannelHandlerContext ctx,
            final ByteBuf in) {
        final ByteBuf out = ctx.nextOutboundByteBuffer();
        out.discardReadBytes();
        out.writeBytes(in);
        ctx.flush();
    }

    @Override
    public void exceptionCaught(final ChannelHandlerContext ctx,
View Full Code Here

                // + willHaveReadByteCount + " framePayloadLength=" +
                // framePayloadLength);
                if (willHaveReadByteCount == framePayloadLength) {
                    // We have all our content so proceed to process
                    payloadBuffer = ctx.alloc().buffer(rbytes);
                    payloadBuffer.writeBytes(in, rbytes);
                } else if (willHaveReadByteCount < framePayloadLength) {

                    // We don't have all our content so accumulate payload.
                    // Returning null means we will get called back
                    if (framePayload == null) {
View Full Code Here

        ByteBuf headerBlock = Unpooled.buffer();
        writeLengthField(version, headerBlock, numHeaders);
        for (String name: names) {
            byte[] nameBytes = name.getBytes(CharsetUtil.UTF_8);
            writeLengthField(version, headerBlock, nameBytes.length);
            headerBlock.writeBytes(nameBytes);
            int savedIndex = headerBlock.writerIndex();
            int valueLength = 0;
            writeLengthField(version, headerBlock, valueLength);
            for (String value: headerFrame.headers().getAll(name)) {
                byte[] valueBytes = value.getBytes(CharsetUtil.UTF_8);
View Full Code Here

            int valueLength = 0;
            writeLengthField(version, headerBlock, valueLength);
            for (String value: headerFrame.headers().getAll(name)) {
                byte[] valueBytes = value.getBytes(CharsetUtil.UTF_8);
                if (valueBytes.length > 0) {
                    headerBlock.writeBytes(valueBytes);
                    headerBlock.writeByte(0);
                    valueLength += valueBytes.length + 1;
                }
            }
            if (valueLength == 0) {
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.