i want to send data from client side to server side when user disconnect from socket.io connection with Nodejsyour text i have try to make another one event and called under disconnect event which is not possible because connection is closed.
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
When a user disconnects from a Socket.IO connection, you can send data from the client-side to the server-side by emitting an event just before the disconnection event occurs. The key is to send the data before the connection is fully closed. Here’s how you can achieve this:
// Emit an event with data just before disconnecting
// Disconnect from the server
On client side, you can use