/// <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); } } }
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; } }
/// <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; }
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); } } }
protected override void DoReadBytes(int position, byte[] dest, int offset, int length) { _buffer.GetBytes(_startPos + position, dest, offset, length); }