how to create URL for viewers in webrtc broadcasting (node js)

Viewed 26

I successfully created the webrtc broadcasting using node js. I add the share URL option for viewers to view the broadcast. I generate the random id in the URL of index.html.The problem is that the previously shared URL can also view the current broadcast video. Now I want to make the URL inactive when the broadcast ends.

when I click the share button, this function is works



function checkId(){
        document.getElementById('uniq').innerHTML = uniqId;
        
        currntUrl = 'http://localhost:4000/index.html?watcher='+ watcherUrl +'broadcaster='+ uniqId;
      
         
          viewUrl = 'index.html?watcher='+ watcherUrl +'broadcaster='+uniqId;
        
         
            window.open(viewUrl);
       
      }

function getRandomString(length) {
  var randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*';
  var resu = '';
  for (var i = 0; i < length; i++) {
    resu += randomChars.charAt(Math.floor(Math.random() * randomChars.length));
  }

  return resu;
}
var broadcastUrl = getRandomString(15);

and I try to get the uniqId value (from broadcast.js or broadcast.html) to watch.js or index.html to validate the random Id, its fails. Has anyone else run into this issue, and is there a better way to do this?

0 Answers
Related