client/index.js
// this function runs the websocket connection and event handlers
this function runs the websocket connection and event handlers
this function runs the websocket connection and event handlers
function connectToWS(e){
  e.preventDefault();
  let name = $inputName.val();
  if(name.trim().length == 0){
    alert('Give me a display name please.');
  }else{
    const userId = getUserId();
    const hue = Math.floor(Math.random() * 350);
    saveHue(hue);
    saveUserName(name);
    wsSetup(userId, name, hue);
  }
}
function connectToWS ( e ) { e . preventDefault ( ) ; let name = $inputName . val ( ) ; if ( name . trim ( ) . length == 0 ) { alert ( 'Give me a display name please.' ) ; } else { const userId = getUserId ( ) ; const hue = Math . floor ( Math . random ( ) * 350 ) ; saveHue ( hue ) ; saveUserName ( name ) ; wsSetup ( userId , name , hue ) ; } }
this function runs the websocket connection and event handlers
this function runs the websocket connection and event handlers
// make sure we have a name chosen for our connection // getting a unique id for this client, use for later to restore connection