/// <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);
        }
Example #2
0
        private IASValue ReadReference()
        {
            // Note: reference ids start with 1 in AMF0.
            int referenceId = input.ReadUnsignedShort();

            if (referenceId < 1 || referenceId > objectReferenceCache.Count)
            {
                throw new AMFException(String.Format(CultureInfo.CurrentCulture,
                                                     ExceptionPrefix + "Encountered Reference token with an object reference id '{0}' that is out of bounds.", referenceId));
            }

            return(objectReferenceCache[referenceId - 1]);
        }
Example #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));
        }