J
J
jslby2014-03-15 17:23:41
Node.js
jslby, 2014-03-15 17:23:41

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

3 answer(s)
V
VoidVolker, 2014-03-15
@VoidVolker

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.

Y
Yuri Shikanov, 2014-03-15
@dizballanze

Without additional authentication, it will not be possible to solve your problem. And that means you will need a database.

P
polanski, 2014-06-17
@polanski

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 question

Ask a Question

731 491 924 answers to any question