예제 #1
0
        /// <summary>
        /// Writes an AMF body.
        /// </summary>
        /// <param name="output">The output stream</param>
        /// <param name="body">The body to write</param>
        private static void WriteAMFBody(AMFDataOutput output, AMFBody body)
        {
            output.WriteShortString(body.RequestTarget);
            output.WriteShortString(body.ResponseTarget);
            output.WriteUnsignedInt(0xffffffff); // body length ignored

            WriteAMFContent(output, body.Content);
        }
예제 #2
0
        public void SpecialConstructorInitializesProperties()
        {
            ASString content = new ASString("abc");
            AMFBody body = new AMFBody("request", "response", content);

            Assert.AreEqual("request", body.RequestTarget);
            Assert.AreEqual("response", body.ResponseTarget);
            Assert.AreSame(content, body.Content);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        public void CanGetAndSetProperties()
        {
            ASString content = new ASString("abc");

            AMFBody body = new AMFBody();

            Assert.IsNull(body.Content);
            body.Content = content;
            Assert.AreSame(content, body.Content);

            Assert.IsNull(body.RequestTarget);
            body.RequestTarget = "abc";
            Assert.AreEqual("abc", body.RequestTarget);

            Assert.IsNull(body.ResponseTarget);
            body.ResponseTarget = "def";
            Assert.AreEqual("def", body.ResponseTarget);
        }
예제 #5
0
        /// <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));
        }
예제 #6
0
        /// <summary>
        /// Writes an AMF body.
        /// </summary>
        /// <param name="output">The output stream</param>
        /// <param name="body">The body to write</param>
        private static void WriteAMFBody(AMFDataOutput output, AMFBody body)
        {
            output.WriteShortString(body.RequestTarget);
            output.WriteShortString(body.ResponseTarget);
            output.WriteUnsignedInt(0xffffffff); // body length ignored

            WriteAMFContent(output, body.Content);
        }
예제 #7
0
 public void AddBody(AMFBody body)
 {
     message.Bodies.Add(body);
 }