I'm writing a chat program with Golang and Gorilla's Websocket toolkit.
I'm wondering if there is a way to run a function whenever a user disconnects or a ping/pong message fails. I need this to remove them from variables and such. Is there any easy way to do this?
The application should close the connection and cleanup variables and such when the read methods (NextReader, ReadMessage) return an error.
Use ping/pong to detect disconnects. The chat example shows how to do this.
If a pong goes missing, the read methods will return with the read past deadline error.