Answer the question
In order to leave comments, you need to log in
How to competently design the backend part of the server API using web sockets?
Hello everybody. Friends! Prompt suitable tutorials or give advice. SPA
is being
done . Frontend - Vue.js , backend - express + swagger . The theme will be something like a toaster. I want to add the maximum realtime out of the box.
Take, for example, tape. How to correctly implement the loading of the tape via websocket, taking into account signed users?
That is, on the server, we add a question to MongoDB and do
it. But do we still need to filter clients by interests? Here I have a complete plug.
There was such an idea: to load a list of tags that the user is subscribed to and cache on the client. And when receiving data from the server, check the tags of the new question and decide on the client whether to draw or not.socket.emit('new-question', questionData);
Am I approaching the decision correctly or am I again tormenting the bike out of crutches?
Answer the question
In order to leave comments, you need to log in
forEach(sockets, function (socket)){
if(socket.user.questionCategoryId === questionData.categoryId) {
socket.emit('new-question', questionData);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question