Package io.netty.buffer

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


    @Override
    protected void flush(ChannelHandlerContext ctx, ByteBuf in, ChannelPromise promise) throws Exception {
        try {
            MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
            ByteBuf payload = Unpooled.buffer(in.readableBytes());
            payload.writeBytes(in);
            out.add(new SctpMessage(streamIdentifier, protocolIdentifier, payload));
        } catch (Throwable t) {
            ctx.fireExceptionCaught(new EncoderException(t));
        }
View Full Code Here


    @Override
    protected void inboundBufferUpdated(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
        meter.mark(in.readableBytes());
        final ByteBuf out = ctx.nextOutboundByteBuffer();
        out.writeBytes(in);
        ctx.flush();
    }
}
View Full Code Here

     * Refer to the source code of {@link ObjectDecoder} to see how this method
     * is overridden to avoid memory copy.
     */
    protected ByteBuf extractFrame(ByteBuf buffer, int index, int length) {
        ByteBuf frame = Unpooled.buffer(length);
        frame.writeBytes(buffer, index, length);
        return frame;
    }

    private void fail(ChannelHandlerContext ctx, long frameLength) {
        if (frameLength > 0) {
View Full Code Here

        ByteBuf buffer = buffer();
        byte[] bytes = new byte[4096 * 4];
        int read = inputStream.read(bytes);
        int written = 0;
        while (read > 0) {
            buffer.writeBytes(bytes, 0, read);
            written += read;
            read = inputStream.read(bytes);
        }
        size = written;
        if (definedSize > 0 && definedSize < size) {
View Full Code Here

            EchoServerHandler.class.getName());

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

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
View Full Code Here

    }

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

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
View Full Code Here

            if (buffer.readableBytes() < dataLength) {
                return null;
            }

            ByteBuf data = ctx.alloc().buffer(dataLength);
            data.writeBytes(buffer, dataLength);
            SpdyDataFrame spdyDataFrame = new DefaultSpdyDataFrame(streamID, data);
            length -= dataLength;

            if (length == 0) {
                spdyDataFrame.setLast((flags & SPDY_DATA_FLAG_FIN) != 0);
View Full Code Here

        ByteBuf footer = Unpooled.buffer();
        synchronized (deflater) {
            deflater.finish();
            while (!deflater.finished()) {
                int numBytes = deflater.deflate(encodeBuf, 0, encodeBuf.length);
                footer.writeBytes(encodeBuf, 0, numBytes);
            }
            if (gzip) {
                int crcValue = (int) crc.getValue();
                int uncBytes = deflater.getTotalIn();
                footer.writeByte(crcValue);
View Full Code Here

  }

  @Override
  protected void write(ByteBuffer data, Promise<Void> onComplete, boolean flush) {
    ByteBuf buf = ioChannel.alloc().buffer(data.remaining());
    buf.writeBytes(data);
    write(buf, onComplete, flush);
  }

  @Override
  protected void write(Object data, final Promise<Void> onComplete, boolean flush) {
View Full Code Here

    return receiver.writerIndex() <= receiver.maxCapacity() - provider.readableBytes();
  }

  private ByteBuf createCombinedBuffer(ByteBuf partOne, ByteBuf partTwo, ChannelHandlerContext ctx) {
    ByteBuf combined = ctx.alloc().buffer(partOne.readableBytes() + partTwo.readableBytes());
    combined.writeBytes(partOne);
    combined.writeBytes(partTwo);
    return combined;
  }

  private void passToConnection(ByteBuf 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.