Amfphp Tutorial Series of Understanding AMF protocol
Action Message Format (AMF)
AMF is a loosely formatted binary format based on the SOAP (Simple Object access Protocol). It is primarily used to exchange data between Adobe Flash applications and data banks via RPC (remote Procedure Call).
Each AMF message contains a subject containing errors and responses, which are expressed as an As object.
AMF is introduced by Flash PLAYER6, which is referenced as AMF0. Until Flash Player9 and As3.0 (when new data types and language styles make an update known as AMF3) have not changed.
Data Types datatype
AMF contains several core data types, which are always present in the data serialization always:
Byte-----A simple 8-bit data. This is the simplest way to transmit data.
Int--------A 16-bit number consists of 2 contiguous bytes. The first byte is more important and the second byte is important.
Mediumint-----A 24-bit number similar to the above, just the difference in length.
Long------A 32-bit number, ditto, but longer.
Double---A 64-digit number consisting of 8 contiguous bytes. Represents a floating-point number with signed numbers. Double is encoded by pressing Little-endian (low byte at the back of the translator not sure hehe).
UTF8---A UTF8 string length less than 2^16 (65536) bytes. It consists of an integer (2 bytes) that represents the length of the string followed by the UTF-8 encoded string.
LongUTF8---A UTF8 string may be longer than 2^16 bytes. It consists of a long integer (4 bytes) representing the length of the string followed by the UTF8 encoded string.
?
Flash 5 starts with the ability toXMLor the "variable/value" pairing output format transmits data to the server. Although this data can be obtained through flashcompilingAutomatically parse or passDevelopmentThe code written by the person is manually parsed, but the parsing speed is slow. Because XML needs to process data on a per-node basis during parsing. And the data types processed using XML and the "variable/value" pairing format can only be character-type, and numbers are no exception. Flash remoting, however, can handle complex data types, such asObjectStructureArrayCan even be a data set, withDataGridComponentsIt is easy to display the data.
To handle complex data types, a unique way to make flash andApplicationIt is imperative that the data be sent back and forth between servers. So AMF was born. AMF isAdobeThe exclusive development ofCommunicationprotocol, which uses binary compression, serializes, deserializes, and transmits data to flashplayerCommunication with Flash Remoting Gateway provides a lightweight, high-performance means of communication. As shown in.
The biggest feature of AMF is that flash built-in objects, such as Object, Array, Date,xml, can be sent back to the server side, and automatically parsed into the appropriate objects on the server side, which reduces the complexity of the developer work, but also saves development time. Because AMF uses binary encoding, this approach can compress data highly, making it ideal for transmitting large amounts of information. The larger the amount of data, the higher the Flash remoting transmission efficiency, far more than webservice. As for XML, Loadvars and LoadvaRiaBles (), they use the pure text transmission, the performance is not even compared with flash remoting.
Note: Flash Remoting requires the browser to support the bin Ary Post,flash player in Nets Cape 6.x. Running Flash Remoting will not work (Flash RemotingcalledNoeffectAlso does not return an error), Nets Cape 7 has corrected this B u g. This is also a problem for early SA Fari and Chim era versions of Macs.
The same is the lightweight data exchange protocol, also by invoking the remote service, also based on the standard HTTP and HTTPS protocol, why did Flash remoting choose to use AMF and discard the soap and Flash Player communication?? There are the following reasons:
SOAP will process data into XML format, and the AFM is too verbose relative to the binary;
AMF can serialize data more efficiently, because AMF is intended only to support the data types of flash ActionScript, while soap is dedicated to providing a wider range of uses;
AMF Support Flash Player 6 only requires the browser to increase the size of about 4 KB (compressed), and soap is mostly;
Some of the header file requests for SOAP are not supported in Flash Player 6. So why does Flash Player 6 have access to SOAP-based Web services? The original Flashremoting gateway converts the SOAP request to the AFM format on the server side and then uses the AFM to communicate with the Flash Player. In addition, the AMF package contains the on
Result Events(such as the response event) and Onstatus events (such as the Error event), which can be used directly in Flash.
AMF has evolved from the AMF0 of the Flash MX era to the present AMF3. The AMF3 is used as the default serialization format for ActionScript3.0 of Flash Playe 9, while AMF0 is used as the legacy version of ActionScript 1.0 and 2.0 for serialization. AMF3 is more likely to transmit data over the network than AMF0 Efficiency。 AMF3 can transfer int and UINT objects as integers (integer), and can serialize data types that are supported by ActionScript 3.0, such as Bytearray,xml and iexternalizable.