/// <summary>
        ///     Decodes the specified region of the buffer into an unadjusted frame length.  The default implementation is
        ///     capable of decoding the specified region into an unsigned 8/16/24/32/64 bit integer.  Override this method to
        ///     decode the length field encoded differently.
        ///     Note that this method must not modify the state of the specified buffer (e.g. <see cref="IByteBuf.ReaderIndex" />,
        ///     <see cref="IByteBuf.WriterIndex" />, and the content of the buffer.)
        /// </summary>
        /// <param name="buffer">The buffer we'll be extracting the frame length from.</param>
        /// <param name="offset">The offset from the absolute <see cref="IByteBuf.ReaderIndex" />.</param>
        /// <param name="length">The length of the framelenght field. Expected: 1, 2, 3, 4, or 8.</param>
        /// <param name="order">The preferred <see cref="ByteOrder" /> of <see cref="buffer" />.</param>
        /// <returns>A long integer that represents the unadjusted length of the next frame.</returns>
        protected long GetUnadjustedFrameLength(IByteBuf buffer, int offset, int length, ByteOrder order)
        {
            buffer = buffer.WithOrder(order);
            long frameLength;

            switch (length)
            {
            case 1:
                frameLength = buffer.GetByte(offset);
                break;

            case 2:
                frameLength = buffer.GetShort(offset);
                break;

            case 4:
                frameLength = buffer.GetInt(offset);
                break;

            case 8:
                frameLength = buffer.GetLong(offset);
                break;

            default:
                throw new DecoderException("unsupported lengthFieldLength: " + lengthFieldLength +
                                           " (expected: 1, 2, 3, 4, or 8)");
            }
            return(frameLength);
        }
Exemplo n.º 2
0
        protected long GetUnadjustedFrameLength(IByteBuf buf, int offset, int length)
        {
            long framelength;

            switch (length)
            {
            case 1:
                framelength = buf.GetByte(offset);
                break;

            case 2:
                framelength = buf.GetShort(offset);
                break;

            case 4:
                framelength = buf.GetInt(offset);
                break;

            case 8:
                framelength = buf.GetLong(offset);
                break;

            default:
                throw new DecoderException(string.Format("unsupported lengtFieldLength: {0} (expected: 1, 2, 4, or 8)", length));
            }
            return(framelength);
        }
Exemplo n.º 3
0
 protected override long _GetLong(int index)
 {
     return(_buffer.GetLong(index));
 }
Exemplo n.º 4
0
 public long GetLong(int index)
 {
     return(ByteBufferUtil.SwapLong(_buf.GetLong(index)));
 }
Exemplo n.º 5
0
 protected override long _GetLong(int index)
 {
     return(_buffer.GetLong(index + _adjustment));
 }
 protected long GetUnadjustedFrameLength(IByteBuf buf, int offset, int length)
 {
     long framelength;
     switch (length)
     {
         case 1:
             framelength = buf.GetByte(offset);
             break;
         case 2:
             framelength = buf.GetShort(offset);
             break;
         case 4:
             framelength = buf.GetInt(offset);
             break;
         case 8:
             framelength = buf.GetLong(offset);
             break;
         default:
             throw new DecoderException(string.Format("unsupported lengtFieldLength: {0} (expected: 1, 2, 4, or 8)", length));
     }
     return framelength;
 }
 /// <summary>
 ///     Decodes the specified region of the buffer into an unadjusted frame length.  The default implementation is
 ///     capable of decoding the specified region into an unsigned 8/16/24/32/64 bit integer.  Override this method to
 ///     decode the length field encoded differently.
 ///     Note that this method must not modify the state of the specified buffer (e.g. <see cref="IByteBuf.ReaderIndex" />,
 ///     <see cref="IByteBuf.WriterIndex" />, and the content of the buffer.)
 /// </summary>
 /// <param name="buffer">The buffer we'll be extracting the frame length from.</param>
 /// <param name="offset">The offset from the absolute <see cref="IByteBuf.ReaderIndex" />.</param>
 /// <param name="length">The length of the framelenght field. Expected: 1, 2, 3, 4, or 8.</param>
 /// <param name="order">The preferred <see cref="ByteOrder" /> of <see cref="buffer" />.</param>
 /// <returns>A long integer that represents the unadjusted length of the next frame.</returns>
 protected long GetUnadjustedFrameLength(IByteBuf buffer, int offset, int length, ByteOrder order)
 {
     buffer = buffer.WithOrder(order);
     long frameLength;
     switch (length)
     {
         case 1:
             frameLength = buffer.GetByte(offset);
             break;
         case 2:
             frameLength = buffer.GetShort(offset);
             break;
         case 4:
             frameLength = buffer.GetInt(offset);
             break;
         case 8:
             frameLength = buffer.GetLong(offset);
             break;
         default:
             throw new DecoderException("unsupported lengthFieldLength: " + lengthFieldLength +
                                        " (expected: 1, 2, 3, 4, or 8)");
     }
     return frameLength;
 }