My understanding: The client makes a request (sends a request) to the server every interval (such as one second). If there is a message on the server, the information is marked in the response (response) to notify the client that there is a new message on the server. The client sends a request to the server to pull the message, and the server responds.
request: Any new news? Please reply if received. response:No. request: Any new news? Please reply if received. response:No. request: Any new news? Please reply if received. response: Yes, the message ID is 123456. request: Please send the message content with message ID 123456. response: Message id: 123456, message text: Surprise! This woman actually did such a thing in front of 1.3 billion people...
Message transmission is obtained by refreshing the client to the server instead of the server sending it directly to the client
In the past, there were indeed some cases where the server directly opened a port locally and the server directly requested the client, but now it is rare to use it for message push (usually used to transfer files or information within the LAN)
The session is stored on the server, and the name and id of the SESSION are stored locally through Cookies. The server uses these two to obtain the content stored on the server side
There are currently two common solutions. 1. The client actively polls (that is, it asks the server every N times if there is any news. 2. The server actively pushes. Sockets are used between back-end services, and websockets can be used to communicate with the front-end.
If it is just one of the many functions of the product, instant messaging recommends that the subject connect to IM, which can save a lot of development expenses. The functions provided by the existing IM providers are relatively comprehensive, and it is much more cost-effective than developing it yourself. You can take a look at the environmental information http://www.easemob.com/
My understanding:
The client makes a request (sends a request) to the server every interval (such as one second).
If there is a message on the server, the information is marked in the response (response) to notify the client that there is a new message on the server.
The client sends a request to the server to pull the message, and the server responds.
request: Any new news? Please reply if received.
response:No.
request: Any new news? Please reply if received.
response:No.
request: Any new news? Please reply if received.
response: Yes, the message ID is 123456.
request: Please send the message content with message ID 123456.
response: Message id: 123456, message text: Surprise! This woman actually did such a thing in front of 1.3 billion people...
Message transmission is obtained by refreshing the client to the server instead of the server sending it directly to the client
In the past, there were indeed some cases where the server directly opened a port locally and the server directly requested the client, but now it is rare to use it for message push (usually used to transfer files or information within the LAN)
The session is stored on the server, and the name and id of the SESSION are stored locally through Cookies. The server uses these two to obtain the content stored on the server side
There are currently two common solutions.
1. The client actively polls (that is, it asks the server every N times if there is any news.
2. The server actively pushes. Sockets are used between back-end services, and websockets can be used to communicate with the front-end.
http2.0 can handle it very well, you can try it~
It is said that it is instant, and a long connection must be established. Such as socket.
If it is just one of the many functions of the product, instant messaging recommends that the subject connect to IM, which can save a lot of development expenses. The functions provided by the existing IM providers are relatively comprehensive, and it is much more cost-effective than developing it yourself. You can take a look at the environmental information http://www.easemob.com/