Пример #1
0
        public static DsoAmfBody Read(AMFReader reader)
        {
            reader.Reset();

            ushort targetUriLen   = reader.ReadUInt16();
            string targetUri      = reader.ReadUTF(targetUriLen);        // When the message holds a response from a remote endpoint, the target URI specifies which method on the local client (i.e. reader request originator) should be invoked to handle the response.
            ushort responseUriLen = reader.ReadUInt16();
            string responseUri    = reader.ReadUTF(responseUriLen);      // The response's target URI is set to the request's response URI with an '/onResult' suffix to denote a success or an '/onStatus' suffix to denote a failure.

            int  numBytes = 4;
            uint dataLen  = 0;

            while (numBytes-- > 0)
            {
                dataLen = (dataLen << 8) | reader.ReadByte();
            }

            // Need to skip 1 byte more, dont know why..
            reader.ReadByte();
            object bodyObj = reader.ReadData();             // turn the element into real data


            DsoAmfBody body = new DsoAmfBody(targetUri, responseUri, bodyObj);

            return(body);
        }
Пример #2
0
		public static DsoAmfBody Read(AMFReader reader) {
			reader.Reset();

			ushort targetUriLen = reader.ReadUInt16();
			string targetUri = reader.ReadUTF(targetUriLen); // When the message holds a response from a remote endpoint, the target URI specifies which method on the local client (i.e. reader request originator) should be invoked to handle the response.
			ushort responseUriLen = reader.ReadUInt16();
			string responseUri = reader.ReadUTF(responseUriLen); // The response's target URI is set to the request's response URI with an '/onResult' suffix to denote a success or an '/onStatus' suffix to denote a failure.

			int numBytes = 4;
			uint dataLen = 0;
			while (numBytes-- > 0)
				dataLen = (dataLen << 8) | reader.ReadByte();

			// Need to skip 1 byte more, dont know why..
			reader.ReadByte();
			object bodyObj = reader.ReadData(); // turn the element into real data


			DsoAmfBody body = new DsoAmfBody(targetUri, responseUri, bodyObj);
			return body;
		}
Пример #3
0
        public void Read(byte[] data)
        {
            using (MemoryStream ms = new MemoryStream(data)) {
                using (AMFReader amf = new AMFReader(ms)) {
                    Header = new List <object>();
                    Bodies = new List <object>();


                    // AMF0_VERSION = 0;
                    // AMF1_VERSION = 1; // There is no AMF1 but FMS uses it for some reason, hence special casing.
                    // AMF3_VERSION = 3;
                    ushort version = amf.ReadUInt16();

                    // Number of headers
                    ushort numHeaders = amf.ReadUInt16();
                    while (numHeaders-- > 0)
                    {
                        var head = DsoAmfHeader.Read(amf);
                        if (head != null)
                        {
                            Bodies.Add(head);
                        }
                    }

                    // Number of bodys
                    ushort numBodies = amf.ReadUInt16();
                    while (numBodies-- > 0)
                    {
                        var body = DsoAmfBody.Read(amf);
                        if (body != null)
                        {
                            Bodies.Add(body);
                        }
                    }
                }
            }
        }