I'm working on a simple chat application using node.js & socket.io.
I'm trying to terminate the connection, for example when the user choose to leave a namespace, or something similar to logout, which doesn't exit the application or trigger a reload.
I've checked this issue @ GitHub, as well as these questions,
- Node.js: socket.io close client connection
- Closing a socket server side on socket.io?
- How to close a socket.io connection
They suggest different methods such as disconnect
, close
etc.
As per my own experiments based on these,
Both disconnect
, close
methods sets the socket's connected
property to false and disconnected
property to true as you can see below.
I've also noticed a destroy
method in the socket's prototype:
Can someone describe what exactly these methods are for, and how they are different from each other..?
Side note: It'd be great if someone can share any reference to documentation for these methods