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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor