Openrtmfp/Cumulus performance optimization (6) rtmfp protocol (3)

Source: Internet
Author: User

The preceding two articles describe the handshake process of the rtmfp protocol. This article describes the connection process of the rtmfp protocol, as follows:

1. Receive packet processing as follows:

(1) read the marker value. uint8 marker = packet. read8 () | 0xf0; the marker value is marker = 0xfd.

(2). Read the values of timesent and lasttimerecv, _ timesent = packet. read16 ();

Uint16 timeecho = packet. read16 ();

(3). Read the typeid value. uint8 type = packet. Available ()> 0? Packet. read8 (): 0xff;

Note: The value of type is 0x10 or 0x11. type = 0x10 indicates a normal request, and type = 0x11 indicates a special request. For example

Is a stage request.

(4) read the flag, IdFlow, stage, and ACK in sequence, as follows:

Flags = message. read8 ();

Uint64 IdFlow = message. read7bitlongvalue ();

Stage = message. read7bitlongvalue ()-1;

Deltanack = message. read7bitlongvalue ()-1;

(5) read the digital signature as follows:

String signature;

Message. readstring8 (signature );

Note: The server will use this digital signature to create a flow for the client with the IdFlow read above,

Flow * pflow = createflow (IdFlow, signature );

(6) parse the Method Name field. The value of method name is "Connect", which is used to establish a connection.

(7) parse the AMF object, which contains some client-related information, as follows:

Amfsimpleobject OBJ;

Message. readsimpleobject (OBJ); // start Parsing

Message. startreferencing ();

(Uri&#peer.swf URL) = obj. getstring ("swfurl", ""); // SWF path

(URI &) Peer. pageurl) = obj. getstring ("pageurl", ""); // page path

(String &) Peer. flashversion) = obj. getstring ("flashver", ""); // version

(8) Respond to the client, meet the connection conditions, and establish a connection, as shown below:

Amfobjectwriter response (writer. writesuccessresponse ("Connect. Success", "connection succeeded "));

Response. Write ("objectencoding", 3.0 );

Accept = peer. onconnection (message, response );

2. The structure of the response packet package is as follows:

1. AMF object is the content written above, for example,

Response (writer. writesuccessresponse ("Connect. Success", "connection succeeded "));

Response. Write ("objectencoding", 3.0 );

("Objectencoding", "3"), ("code", "netconnection. Connect. Success") in JSON format "))

2. For other types like typeid, IdFlow is sent by the CONNECT request, which is not described here.

 

Not complete to be continued ~~

 

Reprinted please indicate the source: zhujian blog, http://blog.csdn.net/linyanwen99/article/details/8668952

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.