Closing WebSocket correctly (HTML5, Javascript)
I am playing around with HTML5 WebSockets. I was wondering, how do I close the connection gracefully? Like, what happens if user refreshes the page, or just closes the browser?
There is a weird behavior when a user just refresh the page without calling websocket.close()
- when they return after the refresh it will hit the websocket.onclose
event.