I\'m using Socket.io, and I\'d like to know the status of connection to the server from the client-side.
Something like this:
socket.status // return
Track the state of the connection yourself. With a boolean. Set it to false
at declaration. Use the various events (connect, disconnect, reconnect, etc.) to reassign the current boolean value. Note: Using undocumented API features (e.g., socket.connected
), is not a good idea; the feature could get removed in a subsequent version without the removal being mentioned.