Answer the question
In order to leave comments, you need to log in
What is the correct way to use socket-io?
For the first time I had to deal with sockets and there were questions regarding its correct use.
I have, for example, a chat application with authorization.
1) I need a socket for all users to display updated online users.
2) I need a socket for logged in users to handle receiving - sending messages.
Is it more correct to do this by connecting different socket instances to different addresses? Or just add some kind of authorize event to the socket, after which additional listeners, events, etc. become available?
And it is still not clear at the moment what logic needs to be shove into sockets.
When loading a chat - I first need to get a list of all messages in the chat that were before the moment I entered. Is it correct to do this also through the socket, or through a regular request to the api?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question