I
I
IDONTSUDO2019-12-07 15:16:44
Node.js
IDONTSUDO, 2019-12-07 15:16:44

socket.io a couple of implementation questions?

I have a newsfeed on my system. Which is generated, like VK. That is, based on events that depend on other users.
I also have HTTP server - MongoDB && Socket server - Redis .
There is a Front End in React.
When you first connect from the Front End `a. I use Socket.io-client to send jwt from which I take UserId , and socket.connection._id I put all this in Redis . Thus, I assign the user to a specific socket session.
1. And so, I need to somehow notify the user that an event has been added to his list of news that he did not read. Do I understand correctly that I need to transfer data from the HTTP server via Soket.io-client to the Soket server and subscribe the user to this event there?
2. Also, the user can be online and offline. Everything is very simple when we want to see what state one user is in, we just go to the radish and take information from there. But when we need to see online or offline list of multiple users. We have 3 options.
2.1. Store data about this in mongo, and also make a tricky scheme. Under which requests will go between servers.
- every time the page is updated on the front, we get a request to go to the database, which, in my opinion, is not very simple.
2.2. store this information in a radish, make a namespace for each user. To which it connects, and thereby check what state the user is in.
- with this option, there are great difficulties with the front-end part. Since some terrible algorithms will have to be prescribed there.
2.3. Store information in a radish, and in order to understand the user's online or offline. Go through the for loop through all UserId and thereby open a socket connection to check each user.
3. How to chat with everyone?
Any help on this matter would be greatly appreciated.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2019-12-07
@megafax

How to pass username to client side using socket.io?
How to send notifications to a specific user in Node.js?
This is?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question