Skip to content

Commit

Permalink
Fixes - Generate Random Peer ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Valar authored and Valar committed Apr 25, 2017
1 parent ba7682e commit 5d65d2e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/peer-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

// Connect to server
var peer = new Peer(generateRandomID(), { host: PEER_SERVER, port: PORT, path: '/', secure: true });
var peer = new Peer(generateRandomID(4), { host: PEER_SERVER, port: PORT, path: '/', secure: true });
// var peer = new Peer({ host: 'my-peer.herokuapp.com', port: '443', path: '/', secure: true });
console.log(peer)

peerCallbacks(peer);
initializeLocalVideo();

// Generate random ID
function generateRandomID() {
// return Math.random().toString(36).substring(2);
return Math.random().toString(36).substring(8);
function generateRandomID(length) {
var chars = '123456789abcdefghijklmnopqrstuvwxyz'
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
return result;
}

// Data channel
Expand Down

0 comments on commit 5d65d2e

Please sign in to comment.