In the previous article, we have introduced the basic situation of the AMF protocol. I believe you have some knowledge about this agreement. Now let's take a brief look at its basic information. Then we will introduce the differences in data processing between the two versions.
The AMF protocol is short for the Action Message Format protocol. The AMF protocol is a protocol of Adobe, which is mainly used for data interaction and Remote Process calling. It is functionally equivalent to WebService, however, the difference between AMF and xml in WebService is that AMF is binary data, while xml is text data, and AMF transmission efficiency is higher than xml. AMF uses http transmission and is currently mainly used in ActionScript, implement communication between Flex and Service. Currently, the latest version is AMF3. The biggest feature of AMF is that it can directly transmit Flash built-in objects, such as Object, Array, Date, XML, to the server, in addition, it is automatically parsed on the server to an appropriate object, which reduces the complex work of developers and saves development time. Because AMF uses binary encoding, this method can compress data highly (misunderstanding of AMF3 in flash), so it is very suitable for transferring a large amount of data 。
The larger the data volume, the higher the transmission efficiency of Flash Remoting, far greater than the Web Service. As for XML, they use plain text transmission, efficiency cannot be compared with Flash Remoting. In addition to AMF encoding for efficient data operations, Byte Array also has a cool function, that is, Copy (Clone) from the memory) for the entire Object, see use Byte Array and AMF to improve the efficiency of Data Object operations 。
There are currently two versions of the AMF protocol, AMF0 and AMF3, which have slightly different definitions of data types 。
- TypeByte codeNotes
- Number0×00
- Boolean0×01
- String0×02
- Object0×03
- MovieClip0×04Not available in Remoting
- Null0×05
- Undefined0×06
- Reference0×07
- MixedArray0×08
- EndOfObject0×09See Object
- Array0x0a
- Date0x0b
- LongString0x0c
- Unsupported0x0d
- Recordset0x0e Remoting, server-to-client only
- XML0x0f
- TypedObject (Class instance)0×10
- AMF3 data0×11 Sent by Flash player 9+
The corresponding enumeration is
- public enum DataType
- {
- Number = 0,
- Boolean = 1,
- String = 2,
- UntypedObject = 3,
- MovieClip = 4,
- Null = 5,
- Undefined = 6,
- ReferencedObject = 7,
- MixedArray = 8,
- End = 9,
- Array = 10,//0x0A
- Date = 11,//0x0B
- LongString = 12,//0x0C
- TypeAsObject = 13,//0x0D
- Recordset = 14,//0x0E
- Xml = 15,//0x0F
- TypedObject = 16,//0x10
- AMF3data=17//0x11
The preceding table lists the representation of each data type of the AMF protocol.