Esempio n. 1
0
        public IChannelBuffer ReadBytes(int length)
        {
            CheckReadableBytes(length);
            if (length == 0)
            {
                return(ChannelBuffers.EmptyBuffer);
            }
            IChannelBuffer buf = Factory.GetBuffer(length);

            buf.WriteBytes(this, _readerIndex, length);
            _readerIndex += length;
            return(buf);
        }
        public IChannelBuffer GetBuffer(IByteBuffer nioBuffer)
        {
            if (nioBuffer.HasArray)
            {
                return(ChannelBuffers.WrappedBuffer(nioBuffer));
            }

            IChannelBuffer buf = GetBuffer((IByteBuffer)nioBuffer.Duplicate());
            int            pos = nioBuffer.ReaderIndex;

            buf.WriteBytes(nioBuffer);
            nioBuffer.SetReaderIndex(pos);
            return(buf);
        }