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 brows
By using close method of web socket, where you can write any function according to requirement.
var connection = new WebSocket('ws://127.0.0.1:1337'); connection.onclose = () => { console.log('Web Socket Connection Closed'); };