Пример #1
0
        private void ReadNextChunk()
        {
            ChannelBuffer readBuffer = ReadNext();

            /* Header layout:
             * [    ,    ][    ,   x] 0: last chunk in message, 1: there a more chunks after this one
             * [    ,    ][    ,  x ] 0: success, 1: failure
             * [    ,    ][xxxx,xx  ] internal protocol version
             * [xxxx,xxxx][    ,    ] application protocol version */
            sbyte[] header = new sbyte[2];
            readBuffer.readBytes(header);
            _more    = (header[0] & 0x1) != 0;
            _failure = (header[0] & 0x2) != 0;
            AssertSameProtocolVersion(header, _internalProtocolVersion, _applicationProtocolVersion);

            if (!_more && _buffer == null)
            {
                // Optimization: this is the first chunk and it'll be the only chunk
                // in this message.
                _buffer = readBuffer;
            }
            else
            {
                _buffer = _buffer == null?ChannelBuffers.dynamicBuffer() : _buffer;

                DiscardReadBytes();
                _buffer.writeBytes(readBuffer);
            }

            if (_failure)
            {
                ReadAndThrowFailureResponse();
            }
        }
Пример #2
0
        /// <summary>
        /// Read a block from the channel. Read the first byte, determine size and if
        /// more are coming, set state accordingly and store content. NOTE: After
        /// this op the buffer is flipped, ready to read.
        /// </summary>
        private void ReadNextBlock()
        {
            int blockSize = _source.readUnsignedByte();

            _byteBuffer.clear();
            _moreBlocks = blockSize == BlockLogBuffer.FULL_BLOCK_AND_MORE;
            int limit = _moreBlocks ? BlockLogBuffer.DataSize : blockSize;

            _byteBuffer.limit(limit);
            _source.readBytes(_byteBuffer);
            _byteBuffer.flip();
        }
Пример #3
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private System.Nullable<sbyte> readContinuationHeader(org.jboss.netty.buffer.ChannelBuffer buffer, final org.jboss.netty.channel.Channel channel)
        private sbyte?ReadContinuationHeader(ChannelBuffer buffer, Channel channel)
        {
            sbyte[] header = new sbyte[2];
            buffer.readBytes(header);
            try
            {               // Read request header and assert correct internal/application protocol version
                assertSameProtocolVersion(header, InternalProtocolVersion, _applicationProtocolVersion);
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final IllegalProtocolVersionException e)
            catch (IllegalProtocolVersionException e)
            {               // Version mismatch, fail with a good exception back to the client
                SubmitSilent(_targetCallExecutor, () => writeFailureResponse(e, NewChunkingBuffer(channel)));
                return(null);
            }
            return(( sbyte )(header[0] & 0x1));
        }
Пример #4
0
 public override ChannelBuffer ReadBytes(int length)
 {
     return(_buffer.readBytes(length));
 }
Пример #5
0
 public override void WriteBytes(ChannelBuffer src, int length)
 {
     sbyte[] array = new sbyte[length];
     src.readBytes(array);
     @delegate.Put(array, array.Length);
 }