Пример #1
0
        public static IChannelBuffer DirectBuffer(int capacity)
        {
            if (capacity == 0)
            {
                return(EmptyBuffer);
            }

            IChannelBuffer buffer = new ByteBufferBackedChannelBuffer(
                Unpooled.Buffer(capacity));

            buffer.Clear();
            return(buffer);
        }
Пример #2
0
        public override void SetBytes(int index, IChannelBuffer src, int srcIndex, int length)
        {
            if (src is ByteBufferBackedChannelBuffer)
            {
                ByteBufferBackedChannelBuffer bbsrc = (ByteBufferBackedChannelBuffer)src;
                IByteBuffer data = bbsrc.Buffer.Duplicate();

                data.Slice(srcIndex, length);
                SetBytes(index, data);
            }
            else if (Buffer.HasArray)
            {
                src.GetBytes(srcIndex, Buffer.Array, index + Buffer.ArrayOffset, length);
            }
            else
            {
                src.GetBytes(srcIndex, this, index, length);
            }
        }
Пример #3
0
 public ByteBufferBackedChannelBuffer(ByteBufferBackedChannelBuffer buffer)
 {
     Buffer = buffer.Buffer;
     SetIndex(buffer.ReaderIndex, buffer.WriterIndex);
 }