Closed ionescu77 closed 4 years ago
var textView = document.getElementById("text-view"); var buttonStop = document.getElementById("stop-button"); buttonStop.onclick = function() { // Close the connection, if open. if (socket.readyState === WebSocket.OPEN) { socket.close(); } }
https://www.tutorialspoint.com/websockets/websockets_closing_connection.htm
It is also possible to pass the code and reason parameters we mentioned earlier as shown below.
socket.close(1000, "Deliberate disconnection");
https://www.tutorialspoint.com/websockets/websockets_closing_connection.htm