client/index.js
// this function handles closing WebSocket connection when unloading or Disconnect button click
this function handles closing WebSocket connection when unloading or Disconnect button click
this function handles closing WebSocket connection when unloading or Disconnect button click
function disconnectWS(){
  if(ws){
    ws.onclose = function () {}; 
    ws.close();
  }
}
function disconnectWS ( ) { if ( ws ) { ws . onclose = function ( ) { } ; ws . close ( ) ; } }
this function handles closing WebSocket connection when unloading or Disconnect button click
this function handles closing WebSocket connection when unloading or Disconnect button click
// disable onclose handler first