AMF
Action Message Format (AMF):
A compact binary format that is used to serialize ActionScript object graphs.
AMF has two versions: AMF 0 and AMF 3.
AMF是一种紧凑的二进制格式。
UTF-8
AMF 0 uses (non-modified) UTF-8 to encode strings.
Serialized UTF-8 strings typically include a header that precedes any character content and specifies the byte-length of the remaining content. The standard header is a 16-bit integer.
A 16-bit byte-length header implies a theoretical maximum of 65,535 bytes to encode a string in UTF-8 (essentially 64KB).
UTF-8字符串由两部分构成:
- 第一部分:
2个字节无符号数,表明字符串的长度。 -
第二部分:
实际的字符串。
AMF 0
AMF 0 Data Types
There are 16 core type markers in AMF 0.
A type marker is one byte in length.
Data Type
用一个字节来表示。
The set of possible type markers are listed below:
number-marker=0x00
boolean-marker=0x01
string-marker=0x02
object-marker=0x03
movieclip-marker=0x04; reserved, not supported
null-marker=0x05
undefined-marker=0x06
reference-marker=0x07
ecma-array-marker=0x08
object-end-marker=0x09
strict-array-marker=0x0A
date-marker=0x0B
long-string-marker=0x0C
unsupported-marker=0x0D
recordset-marker=0x0E; reserved, not supported
xml-document-marker=0x0F
typed-object-marker=0x10
Number Type
The data following a Number type marker is always an 8 byte IEEE-754 double precision floating point value in network byte order (sign bit in low memory).
number-type=number-marker DOUBLE
Boolean Type
A Boolean type marker is followed by an unsigned byte; a zero byte value denotes false while a non-zero byte value (typically 1) denotes true.
boolean-type=boolean-marker U8 ; 0 is false, <> 0 is true
String Type
All strings in AMF are encoded using UTF-8; however, the byte-length header format may vary.
The AMF 0 String type uses the standard byte-length header (i.e. U16).
For long Strings that require more than 65535 bytes to encode in UTF-8, the AMF 0 Long String type should be used.
string-type=string-marker UTF-8
Object Type
The AMF 0 Object type is used to encoded anonymous ActionScript objects.
Any typed object that does not have a registered class should be treated as an anonymous ActionScript object.
If the same object instance appears in an object graph it should be sent by reference using an AMF 0.
Use the reference type to reduce redundant information from being serialized and infinite loops from cyclical references.
*object-property =
(UTF-8 value-type)
| (UTF-8-empty object-end-marker)
anonymous-object-type=object-marker (object-property)
null Type
The null type is represented by the null type marker. No further information is encoded for this value.
null-type=null-marker
ECMA Array Type
Object End Type
The object-end-marker is used in a special type that signals the end of a set of object properties in an anonymous object or typed object or associative array.
It is not expected outside of these types.
This marker is always preceded by an empty UTF-8 string and together forms the object end type.
用于表示a set of object properties
的结束等。
References:
amf0-file-format-specification.pdf