Search in sources :

Example 1 with DynamicChannelBuffer

use of org.jboss.netty.buffer.DynamicChannelBuffer in project MSEC by Tencent.

the class RequestDecoder method setAttachment.

private void setAttachment(ChannelHandlerContext ctx, Channel channel, ChannelBuffer cb, int lastReadIndex) {
    cb.readerIndex(lastReadIndex);
    if (!(cb instanceof DynamicChannelBuffer) || cb.writerIndex() > 102400) {
        ChannelBuffer db = ChannelBuffers.dynamicBuffer(cb.readableBytes() * 2, channel.getConfig().getBufferFactory());
        db.writeBytes(cb);
        cb = db;
    }
    NettyCodecUtils.setAttachment(ctx, Constants.ATTACHMENT_BYTEBUFFER, cb);
}
Also used : DynamicChannelBuffer(org.jboss.netty.buffer.DynamicChannelBuffer) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) DynamicChannelBuffer(org.jboss.netty.buffer.DynamicChannelBuffer)

Example 2 with DynamicChannelBuffer

use of org.jboss.netty.buffer.DynamicChannelBuffer in project MSEC by Tencent.

the class ResponseDecoder method setAttachment.

private void setAttachment(ChannelHandlerContext ctx, Channel channel, ChannelBuffer cb, int lastReadIndex) {
    cb.readerIndex(lastReadIndex);
    if (!(cb instanceof DynamicChannelBuffer) || cb.writerIndex() > 102400) {
        ChannelBuffer db = ChannelBuffers.dynamicBuffer(cb.readableBytes() * 2, channel.getConfig().getBufferFactory());
        db.writeBytes(cb);
        cb = db;
    }
    NettyCodecUtils.setAttachment(ctx, Constants.ATTACHMENT_BYTEBUFFER, cb);
}
Also used : DynamicChannelBuffer(org.jboss.netty.buffer.DynamicChannelBuffer) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) DynamicChannelBuffer(org.jboss.netty.buffer.DynamicChannelBuffer)

Example 3 with DynamicChannelBuffer

use of org.jboss.netty.buffer.DynamicChannelBuffer in project camel by apache.

the class NettyConverterTest method startUp.

@Before
public void startUp() {
    byte[] bytes = PAYLOAD.getBytes();
    buf = new DynamicChannelBuffer(bytes.length);
    buf.writeBytes(bytes);
}
Also used : DynamicChannelBuffer(org.jboss.netty.buffer.DynamicChannelBuffer) Before(org.junit.Before)

Aggregations

DynamicChannelBuffer (org.jboss.netty.buffer.DynamicChannelBuffer)3 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)2 Before (org.junit.Before)1