I'm using Node-RED as server to manage websockets sessions.
One of my biggest problems is to detect when a session is disconnecting. With classic NodeJS we have an event onClose. But i don't know how to do it in Node-RED.
When a client is disconnecting i would like to have a msg with session and a payload object like "disconnected".
Are you using the websocket nodes? I'm not sure that they support a disconnect event. I think they use raw websockets and I'm not even sure how much you can trust any disconnect events since the client might simply go away without shutting down. So you might be reliant on a ping/pong message - again, not sure if that is available in raw websockets.
Sorry, sounding rather vague there. I mostly work with socket.io.
It works !!! Thank you !
With status node you receive message on connected and disconnect event with the websocket session.
Now i can easely control my differents clients websocket sessions.