Exemplo n.º 1
0
      /// <summary>
      /// Read a short string from the buffer
      /// </summary>
      /// <param name="buffer">The buffer to read from.</param>
      /// <returns>a string</returns>
      /// <exception cref="AMQFrameDecodingException">if the buffer does not contain a decodable short string</exception>
      public static string ReadShortString(ByteBuffer buffer)
      {
         byte length = buffer.GetByte();
         if ( length == 0 )
         {
            return null;
         } else
         {
            byte[] data = new byte[length];
            buffer.GetBytes(data);

            lock ( DEFAULT_ENCODER )
            {
               return DEFAULT_ENCODER.GetString(data);
            }
         }
      }
Exemplo n.º 2
0
 public static byte[] ReadLongstr(ByteBuffer buffer)
 {
    uint length = buffer.GetUInt32();
    if ( length == 0 )
    {
       return null;
    } else
    {
       byte[] result = new byte[length];
       buffer.GetBytes(result);
       return result;
    }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Decodes the specified session.
 /// </summary>
 /// <param name="inbuf">The inbuf.</param>
 /// <param name="output">The protocol output.</param>
 /// <returns></returns>
 public MessageDecoderResult Decode(ByteBuffer inbuf, IProtocolDecoderOutput output)
 {
     byte[] header = new byte[4];
     inbuf.GetBytes(header);
     ProtocolInitiation pi = new ProtocolInitiation();
     pi.Header = new char[]{'A','M','Q','P'};
     pi.ProtocolClass = inbuf.GetByte();
     pi.ProtocolInstance = inbuf.GetByte();
     pi.ProtocolMajor = inbuf.GetByte();
     pi.ProtocolMinor = inbuf.GetByte();
     output.Write(pi);
     return MessageDecoderResult.OK;
 }
Exemplo n.º 4
0
 public static string ReadLongString(ByteBuffer buffer, Encoding encoding)
 {
    uint length = buffer.GetUInt32();
    if ( length == 0 )
    {
       return null;
    } else
    {
       byte[] data = new byte[length];
       buffer.GetBytes(data);
       lock ( encoding )
       {
          return encoding.GetString(data);
       }
    }
 }
Exemplo n.º 5
0
 protected override void DoReadBytes(int position, byte[] dest, int offset, int length)
 {
     _buffer.GetBytes(_startPos + position, dest, offset, length);
 }