Home >Backend Development >PHP Tutorial >javascript - Real-time push of forum information

javascript - Real-time push of forum information

WBOY
WBOYOriginal
2016-09-13 09:00:151002browse

I would like to ask a question. I want to implement real-time push of messages in a web forum. The front and back ends are separated. The middle layer is made of node. I plan to use socket.io to establish a long connection between the client and the node, and the node does not have to keep track of the back end. To maintain a long connection, the node side provides an interface. When the backend has a message, it calls the interface and tells the node side to deliver what message to whom. How should we determine whether the client is online, that is, a long connection has been established with the node? If the corresponding user is found based on the information provided by the backend, such as user ID, and the message is delivered?

Reply content:

I would like to ask a question. I want to implement real-time push of messages in a web forum. The front and back ends are separated. The middle layer is made of node. I plan to use socket.io to establish a long connection between the client and the node, and the node does not have to keep track of the back end. To maintain a long connection, the node side provides an interface. When the backend has a message, it calls the interface and tells the node side to deliver what message to whom. How should we determine whether the client is online, that is, a long connection has been established with the node? If the corresponding user is found based on the information provided by the backend, such as user ID, and the message is delivered?

Just send a message directly to a single person

Statement:
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