Answer the question
In order to leave comments, you need to log in
Saving and setting a socket - how to implement?
I am writing a chat, and I saw such a moment, if you restart the server, then a completely new socket.id is assigned for each user.
I would like to keep it somehow. Is it possible to do this with some socket.io add-on without using cookies and db?
Answer the question
In order to leave comments, you need to log in
No way. No, you can certainly save something somewhere without problems, but why? The socket ID is issued by the OS when the connection is established, if the connection breaks (and it breaks, because the application restarts), then the socket is destroyed. Accordingly, an attempt to transmit data through a non-existent socket will result in an exception.
Without additional authentication, it will not be possible to solve your problem. And that means you will need a database.
Node.js Almost none. )))
I am writing a chat server. Clients are all console. Communicate individually, that is, there is no "broadcasting at all."
Question 1.
Is it possible in NODE js to somehow arrange a dynamically growing array of the type:
[id1] [socket_in] [socket_out]
[id2] [socket_in] [socket_out]
....
[idn] [socket_in] [socket_out]
Question 2.
If I already have a mySQL database, how can I store the socket in it? What type of cell can do this?
I don't know myself (((
Thanks for the help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question