client/webrtc.js
//generate a random identifier and capture a user-entered display name

generate a random identifier and capture a user-entered display name
generate a random identifier and capture a user - entered display name
function start() {  
  localUuid = createUUID();  
  var urlParams = new URLSearchParams(window.location.search); 
 localDisplayName =  urlParams.get('displayName') || prompt('Enter your name', ''); 
  document.getElementById('localVideoContainer').appendChild(makeLabel(localDisplayName)); 
  downlinkspeed()
  if (navigator.mediaDevices.getUserMedia) { 
    navigator.mediaDevices.getUserMedia(constraints) 
      .then(stream => {
        localStream = stream;
        document.getElementById('localVideo').srcObject = stream; 
      }).catch(errorHandler) 
      .then(() => {
        serverConnection = new WebSocket('wss://' + window.location.hostname);
        serverConnection.onmessage = gotMessageFromServer; 
        serverConnection.onopen = event => { 
          setTimeout(function(){serverConnection.send(JSON.stringify({ 'displayName': localDisplayName, 'uuid': localUuid, 'dest': 'all', "time": time }))},2000 );
        }
      }).catch(errorHandler);
  } else { 
    alert('Your browser does not support getUserMedia API');
  }
  var myDiv = document.getElementById("GFG");
  var button = document.createElement('BUTTON');
  button.setAttribute('id', "raiseHand"); 
  var text = document.createTextNode("Raise Hand"); 
  button.appendChild(text); 
  myDiv.appendChild(button);
  var raiseHandButton = document.getElementById("raiseHand");
  raiseHandButton.onclick = function(){
    raiseHandClient=1;
    lowerHandDown=1;
    serverConnection.send(JSON.stringify({'displayName': localDisplayName, "raiseHand": true, "uuid": localUuid}));
    alert("Please wait while master accepts your request.");  
  };
}
function start ( ) { localUuid = createUUID ( ) ; var urlParams = new URLSearchParams ( window . location . search ) ; localDisplayName = urlParams . get ( 'displayName' ) || prompt ( 'Enter your name' , '' ) ; document . getElementById ( 'localVideoContainer' ) . appendChild ( makeLabel ( localDisplayName ) ) ; downlinkspeed ( ) if ( navigator . mediaDevices . getUserMedia ) { navigator . mediaDevices . getUserMedia ( constraints ) . then ( stream => { localStream = stream ; document . getElementById ( 'localVideo' ) . srcObject = stream ; } ) . catch ( errorHandler ) . then ( ( ) => { serverConnection = new WebSocket ( 'wss://' + window . location . hostname ) ; serverConnection . onmessage = gotMessageFromServer ; serverConnection . onopen = event => { setTimeout ( function ( ) { serverConnection . send ( JSON . stringify ( { 'displayName' : localDisplayName , 'uuid' : localUuid , 'dest' : 'all' , "time" : time } ) ) } , 2000 ) ; } } ) . catch ( errorHandler ) ; } else { alert ( 'Your browser does not support getUserMedia API' ) ; } var myDiv = document . getElementById ( "GFG" ) ; var button = document . createElement ( 'BUTTON' ) ; button . setAttribute ( 'id' , "raiseHand" ) ; var text = document . createTextNode ( "Raise Hand" ) ; button . appendChild ( text ) ; myDiv . appendChild ( button ) ; var raiseHandButton = document . getElementById ( "raiseHand" ) ; raiseHandButton . onclick = function ( ) { raiseHandClient = 1 ; lowerHandDown = 1 ; serverConnection . send ( JSON . stringify ( { 'displayName' : localDisplayName , "raiseHand" : true , "uuid" : localUuid } ) ) ; alert ( "Please wait while master accepts your request." ) ; } ; }
generate a random identifier and capture a user-entered display name
generate a random identifier and capture a user - entered display name
//create a unique identification id for every new peer
 // returns a URLSearchParams() object instance.
 // check if "&displayName=xxx" is appended to URL, otherwise alert user to populate
 //append the displayName to the localVideoContainer
 //calculating bandwidth
 // set up local video stream
 //to check that the browser supports getUserMedia API
 //prompts the user for permission to use up to one video input device and up to one audio input device 
 //the stream is assigned to localVideo
 // set up websocket and message all existing clients
 //serverConnection = new WebSocket('wss://' + "172.16.36.100:8443");
 // on getting a message from the server call gotMessageFromServer
 //when the connection is open send localDisplayName and localUuid to all peers, settimeout is used so that this message gets send once time is calculated
 //if the browser does not support getUserMedia API issue an alert
 //Creating a button for raise hand requests
 // creating button element  
 // creating text to be 
 //displayed on button 
 // appending text to button 
 // appending button to div 
 //Add onclick event
