/// <summary> /// Writes an AMF header. /// </summary> /// <param name="output">The output stream</param> /// <param name="header">The header to write</param> private static void WriteAMFHeader(AMFDataOutput output, AMFHeader header) { output.WriteShortString(header.Name); output.WriteBoolean(header.MustUnderstand); output.WriteUnsignedInt(0xffffffff); // header length ignored WriteAMFContent(output, header.Content); }
/// <summary> /// Writes an AMF header. /// </summary> /// <param name="output">The output stream</param> /// <param name="header">The header to write</param> private static void WriteAMFHeader(AMFDataOutput output, AMFHeader header) { output.WriteShortString(header.Name); output.WriteBoolean(header.MustUnderstand); output.WriteUnsignedInt(0xffffffff); // header length ignored WriteAMFContent(output, header.Content); }
public void SpecialConstructorInitializesProperties() { ASString content = new ASString("abc"); AMFHeader header = new AMFHeader("header", true, content); Assert.AreEqual("header", header.Name); Assert.IsTrue(header.MustUnderstand); Assert.AreEqual(content, header.Content); }
/// <summary> /// Reads an AMF message from an input stream and bubbles up exceptions. /// </summary> /// <param name="input">The input stream</param> /// <param name="firstByte">The first byte of the message</param> /// <returns>The AMF message that was read</returns> private static AMFMessage UncheckedReadAMFMessage(AMFDataInput input, byte firstByte) { byte secondVersionByte = input.ReadByte(); ushort version = (ushort) ((firstByte << 8) | secondVersionByte); int headerCount = input.ReadUnsignedShort(); AMFHeader[] headers = new AMFHeader[headerCount]; for (int i = 0; i < headerCount; i++) headers[i] = ReadAMFHeader(input); int bodyCount = input.ReadUnsignedShort(); AMFBody[] bodies = new AMFBody[bodyCount]; for (int i = 0; i < bodyCount; i++) bodies[i] = ReadAMFBody(input); return new AMFMessage(version, headers, bodies); }
public void CanGetAndSetProperties() { ASString content = new ASString("abc"); AMFHeader header = new AMFHeader(); Assert.IsNull(header.Content); header.Content = content; Assert.AreSame(content, header.Content); Assert.IsFalse(header.MustUnderstand); header.MustUnderstand = true; Assert.IsTrue(header.MustUnderstand); Assert.IsNull(header.Name); header.Name = "abc"; Assert.AreEqual("abc", header.Name); }
/// <summary> /// Reads an AMF message from an input stream and bubbles up exceptions. /// </summary> /// <param name="input">The input stream</param> /// <param name="firstByte">The first byte of the message</param> /// <returns>The AMF message that was read</returns> private static AMFMessage UncheckedReadAMFMessage(AMFDataInput input, byte firstByte) { byte secondVersionByte = input.ReadByte(); ushort version = (ushort)((firstByte << 8) | secondVersionByte); int headerCount = input.ReadUnsignedShort(); AMFHeader[] headers = new AMFHeader[headerCount]; for (int i = 0; i < headerCount; i++) { headers[i] = ReadAMFHeader(input); } int bodyCount = input.ReadUnsignedShort(); AMFBody[] bodies = new AMFBody[bodyCount]; for (int i = 0; i < bodyCount; i++) { bodies[i] = ReadAMFBody(input); } return(new AMFMessage(version, headers, bodies)); }