Understanding of AMFPHP course series AMF protocol

Source: Internet
Author: User
Tags nets
AMFPHP tutorial series: Understanding AMF protocol ActionMessageFormat (AMF) AMF is a loose binary format based on SOAP (SimpleObjectAccessProtocol, Simple Object Access Protocol. It is mainly used to understand the AMF protocol in the AdobeFlash application AMFPHP tutorial series.

Action Message Format (AMF)
AMF is a loose binary format based on SOAP (Simple Object Access Protocol. It is mainly used to exchange data between Adobe Flash applications and databases through RPC (remote process call ).
Each AMF message contains a subject containing errors and responses, which are expressed As an As object.
AMF was introduced by Flash Player6. this version was referenced as AMF0. it has not been changed until Flash Player9 and As3.0 (the new data type and language style make an update called AMF3.
Data Types Data type
AMF contains several core data types, which always exist in data serialization:
Byte ----- a simple 8-bit data. This is the simplest way to transmit data.
Int -------- a 16-digit number consists of two consecutive bytes. The first byte is important, and the second byte is important.
MediumInt ----- a 24-digit number is similar to the preceding one, but only the length difference.
Long ------ a 32-bit number, same as above, but longer.
Double --- a 64-bit number consists of eight consecutive bytes. Represents a floating point signed number. Double is followed by little-endian (low byte? The translator is not sure.) encoding.
UTF8 --- the length of a UTF-8 string is less than 2 ^ 16 (65536) bytes. It is represented by an integer (2 bytes) the length of the string, followed by the UTF-8 encoded string.
LongUTF8 --- a UTF-8 string may be longer than 2 ^ 16 bytes. It consists of a long integer (4 bytes) indicating the length of a string, followed by a UTF-8 encoded string.

?

From Flash 5, data can be transmitted to the server in XML or variable/value pairs. Although the data can be automatically parsed using the Flash compiler or manually parsed using the code compiled by the developer, the parsing speed is slow. In the parsing process, XML needs to process data layer by node. In addition, the data type processed in XML and "variable/value" matching formats can only be numeric, and numbers are no exception. Flash Remoting can process complex data types, such as objects, structures, arrays, and even datasets. it can be used with the DataGrid component to conveniently display data.

To process complex data types, it is imperative to use a unique method to transfer data between Flash and the application server. So AMF came into being. AMF is an exclusive communication protocol developed by Adobe. it adopts binary compression, serialization, deserialization, and data transmission, this provides a lightweight and efficient communication mode for the Flash Player to communicate with the Flash Remoting gateway. As shown in.


The biggest feature of AMF is that Flash built-in objects such as Object, Array, Date, and XML can be directly transmitted back to the server and automatically parsed to appropriate objects on the server, this reduces the complex work of developers and saves development time. Because AMF uses binary encoding, this method can compress data highly, 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 exceeding WebService. For XML, LoadVars, and loadVariables (), they use plain text transmission methods, and their performance cannot be compared with Flash Remoting.

Note: Flash Remoting requires the browser to support Bin ary POST, and the Flash player is in Nets cape 6. x. running Flash Remoting in the environment does not work (The Flash Remoting call has no effect and no error is returned). Nets cape 7 has corrected the B u g. This problem also exists for early versions of the Sa fari and Chim era Apple servers.

It is also a lightweight data exchange protocol, also by calling remote services, also based on standard HTTP and HTTPS protocols, why does Flash Remoting choose to use AMF and discard the communication between SOAP and Flash players ?? There are the following reasons:

SOAP processes data in XML format, which is too lengthy compared with the binary file system;
AMF can more effectively serialize data, because AMF was originally designed to support the data types of Flash ActionScript, but SOAP is committed to providing a wider range of uses;
AMF supports Flash Player 6, which only requires a browser to increase the size of around 4 KB (after compression), while SOAP is mostly used;
Some SOAP header file requests are not supported in Flash Player 6. Why does Flash Player 6 access the SOAP-based Web service? In the past, FlashRemoting gateway converted the SOAP request on the server to an atom file format, and then communicated with the Flash player using the atom file. In addition, the AMF package contains the on

Result events (such as response events) and onStatus events (such as error events) can be directly used in Flash.
AMF has evolved from AMF0 in The Flash MX era to AMF3. AMF3 is used as the default serialization format of ActionScript3.0 of Flash Playe 9, while AMF0 is used as the serialization format of the old versions of ActionScript 1.0 and 2.0. In terms of network data transmission, AMF3 is more efficient than AMF0. AMF3 can transmit int and uint objects as integers, and serializes data types supported by ActionScript 3.0, such as ByteArray, XML, and Iexternalizable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.