M
M
mint_candy2019-05-28 21:03:57
Node.js
mint_candy, 2019-05-28 21:03:57

How to deliver a message to those users whose socket is not active?

Good day to all. Learning the basics of Socket.io ran into a problem.
Suppose there is a certain room ( information about which is stored in the database, as well as ID and Socket.id of each client are stored, and socket.id is updated when reconnecting).
Users, when authenticating on the server and calling the joinRoom event, join the room, and when disconnected, he leaves the room (formally disconnects from the server, and it is this socket that leaves the room, but not the user).
Suppose some socket is broadcasting a message to the room. The message, of course, will be delivered immediately to all online users than the socket is now known to, well, it will be saved to the database. But what about those users who are not online now, but their socket will become known when connected? I do not quite understand how to track this moment.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2019-05-28
@mint_candy

When logging into the room, send messages that were not delivered, for example. The server knows that the user has connected and can start a chain of search and forwarding of messages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question