Summary of WeChat Development Agreement

高洛峰
Release: 2017-03-13 13:33:49
Original
1596 people have browsed it

Through this tutorial, I will share with you the WeChat development protocolSummaryThe relevant knowledge explained is very good and has certain reference value. Friends who are interested should take a look together

1. The published message corresponds to an ID (as long as it is unique in a single direction, the service server may judge repeated reception based on the ID). The message retransmission mechanism ensures a limited number of retries. If the retry fails, the user will be prompted. A confirmation message will be sent back if the message is sent successfully. The client will not know that the message was sent successfully until it receives the confirmation message. Sending Message may not generate a new SyncKey.

2. Based on the version number (SynKey) status message synchronization mechanism, incremental and orderly transmission requirements are naturally fulfilled. Long connection notification/short connection acquisition, confirmation, etc., the interaction method is simple, ensuring that messages arrive reliably and accurately.

3. The client/server will store message ID processing records to avoid repeated consumption. The client obtains the latest message, but it is not confirmed. The server will not consider the message to be consumed. The client will obtain it again next time and will querywhether the current message has been processed. Guess based on some phenomena.

4. Generally speaking, the WeChat protocol is cross-platform (TCP or HTTP can be presented, and the processing method can be unified). It is synchronized through "handshake" and is very reliable. No matter which platform it is, it can be supported very well

5. The minimum cost of the WeChat protocol is 16 bytes. Most of the time, several message packages are combined together and transmitted in batches. The WeChat protocol is neither the simplest nor the most traffic-saving, but it is very successful.

6. If the server detects some uncertain factors, it may cause the micro-enablement of the Security socket layer SSL protocol for regular TCP long connection transmission. The short connection has not changed

7. Sending message method

Send a message through the established TCP long connection channel, send the message to the server, and then accept the confirmation message, etc., resulting in an interaction.

When friends receive information and read it, they will also receive server-side notifications, resulting in an interaction, etc.

It can be determined that WeChat uses TCP long connection mode to send messages. Since it does not affect its own status data, SyncKey should not be exchanged.

Under a low-speed network, you may see a message sending message, which belongs to the message resending mechanism

If the network is not good, sometimes the client will display a red exclamation mark indicating that the sending failed

The message has been sent to the server but has not been confirmed. The client displays a red exclamation mark and resends again. The server treats it as a duplicate message and feedback confirmation

UploadPicture, will be divided into several parts according to the size of the image (about 1.5K is divided into parts). At the same time point, the client will initiate several POST requests. After each upload is successful, the server will probably merge it into A complete picture returns a thumbnail, which is displayed in the APP chat window. The APP sends it to the server as a regular text message

UploadAudio, then it goes through the TCP channel alone, a two-second audio recording. After the client has finished recording, it is divided into two parts for transmission, one The maximum size is about 1.5K, and the server responds with a data notification to confirm receipt. A total of three data transfers.

Audio and plain text information are the same. They are both sent via TCP long connection, sent by the client and confirmed by the server.

The above is a summary of the WeChat development protocol that the editor introduces to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. of. I would also like to thank you all for your support of the Script House website!

The above is the detailed content of Summary of WeChat Development Agreement. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template