/// <summary> /// The read packet body. /// </summary> /// <param name="stream"> /// The stream. /// </param> /// <returns> /// The <see cref="AmfMessageDescriptor"/>. /// </returns> /// <exception cref="FormatException"> /// </exception> public override sealed AmfMessageDescriptor ReadPacketBody(Stream stream) { var reader = new AmfStreamReader(stream); AmfContext context = this.CreateDefaultContext(); try { var descriptor = new AmfMessageDescriptor { Target = ReadString(reader), Response = ReadString(reader) }; reader.ReadInt32(); // Message length context.ResetReferences(); return(descriptor); } catch (Exception e) { throw new FormatException(Errors.Amf0Deserializer_ReadPacketMessages_InvalidFormat, e); } }
/// <summary> /// The read packet header. /// </summary> /// <param name="stream"> /// The stream. /// </param> /// <returns> /// The <see cref="AmfHeaderDescriptor"/>. /// </returns> /// <exception cref="FormatException"> /// </exception> public override sealed AmfHeaderDescriptor ReadPacketHeader(Stream stream) { var reader = new AmfStreamReader(stream); AmfContext context = this.CreateDefaultContext(); try { var descriptor = new AmfHeaderDescriptor { Name = ReadString(reader), MustUnderstand = reader.ReadBoolean() }; reader.ReadInt32(); // Header length context.ResetReferences(); return(descriptor); } catch (Exception e) { throw new FormatException(Errors.Amf0Deserializer_ReadPacketHeaders_InvalidFormat, e); } }