R
R
RedDokC22017-05-29 21:44:38
JavaScript
RedDokC2, 2017-05-29 21:44:38

How to save data before disconnecting user (socket.io)?

When the user connects, I write different data to and when the user disconnects, I need to write them to NeDB, but with the disconnect event
socket.username = {"auth" : false ......};

socket.on('disconnect', function(){
});

I learn about disconnecting the user when the socket no longer exists and the data too.
How can I write the data to the database then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2017-05-29
@RedDokC2

After a disconnect, the socket object does not cease to exist, all data in it is preserved.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question