Package io.netty.buffer

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


                        }

                        if (result.bytesProduced() > 0) {
                            outNetBuf.flip();
                            msg = ChannelBuffers.buffer(outNetBuf.remaining());
                            msg.writeBytes(outNetBuf.array(), 0, msg.capacity());
                            outNetBuf.clear();

                            if (pendingWrite.outAppBuf.hasRemaining()) {
                                // pendingWrite's future shouldn't be notified if
                                // only partial data is written.
View Full Code Here


                }

                if (result.bytesProduced() > 0) {
                    outNetBuf.flip();
                    ChannelBuffer msg = ChannelBuffers.buffer(outNetBuf.remaining());
                    msg.writeBytes(outNetBuf.array(), 0, msg.capacity());
                    outNetBuf.clear();

                    future = future(channel);
                    future.addListener(new ChannelFutureListener() {
                        @Override
View Full Code Here

            outAppBuf.flip();

            if (outAppBuf.hasRemaining()) {
                ChannelBuffer frame = ChannelBuffers.buffer(outAppBuf.remaining());
                frame.writeBytes(outAppBuf.array(), 0, frame.capacity());
                return frame;
            } else {
                return null;
            }
        } catch (SSLException e) {
View Full Code Here

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

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

            // the cumulation buffer is not created yet so just pass the input to callDecode(...) method
            callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
            if (input.readable()) {
                // seems like there is something readable left in the input buffer. So create the cumulation buffer and copy the input into it
                ChannelBuffer cumulation = cumulation(ctx);
                cumulation.writeBytes(input);
            }
        } else {
            ChannelBuffer cumulation = cumulation(ctx);
            if (cumulation.readable()) {
                cumulation.discardReadBytes();
View Full Code Here

            }
        } else {
            ChannelBuffer cumulation = cumulation(ctx);
            if (cumulation.readable()) {
                cumulation.discardReadBytes();
                cumulation.writeBytes(input);
                callDecode(ctx, e.getChannel(), cumulation, e.getRemoteAddress());
            } else {
                callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
                if (input.readable()) {
                    cumulation.writeBytes(input);
View Full Code Here

                cumulation.writeBytes(input);
                callDecode(ctx, e.getChannel(), cumulation, e.getRemoteAddress());
            } else {
                callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
                if (input.readable()) {
                    cumulation.writeBytes(input);
                }
            }
        }
       
    }
View Full Code Here

                loop: for (;;) {
                    // Decompress 'in' into 'out'
                    int resultCode = z.inflate(JZlib.Z_SYNC_FLUSH);
                    if (z.next_out_index > 0) {
                        decompressed.writeBytes(out, 0, z.next_out_index);
                        z.avail_out = out.length;
                    }
                    z.next_out_index = 0;

                    switch (resultCode) {
View Full Code Here

        }

        ChannelBuffer cumulation = cumulation(ctx);
        needsCleanup = true;
        cumulation.discardReadBytes();
        cumulation.writeBytes(input);
        callDecode(ctx, e.getChannel(), cumulation, e.getRemoteAddress());
    }

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

        // Construct a message.
        ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
        buf.writeByte((byte) 'F'); // magic number
        buf.writeInt(dataLength)// data length
        buf.writeBytes(data);      // data

        // Return the constructed message.
        return buf;
    }
}
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.