How socket.io Communicates in Real Time Based on Users of Existing Databases

  node.js, question

The specific requirements are as follows:

  • Realize the function of real-time notification between users.

  • That is, user A will send a real-time notification to user B if it triggers an event. (if user b is online)

Current problems:

  • Most demo on the internet are session-based and do not exist after refreshing or closing.

  • If a user connection already exists, what should I do?


Just give me some ideas

First of all, the messages of A->B should be sent through the server and marked unread at the same time. if user b is online, then user b will send a request to mark the received message as read, that is, received. When the time comes for user b to go online, just pull down his unread message.