diff --git a/client/random.js b/client/random.js new file mode 100644 index 0000000..e79ccfd --- /dev/null +++ b/client/random.js @@ -0,0 +1,9 @@ +// Taken from http://stackoverflow.com/a/105074/515584 +// Strictly speaking, it's not a real UUID, but it gets the job done here +export function createUUID() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); + } + + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); +} diff --git a/client/webrtc.js b/client/webrtc.js index e3594ee..1576b89 100755 --- a/client/webrtc.js +++ b/client/webrtc.js @@ -1,4 +1,5 @@ import { dataChannelConfig, peerConnectionConfig } from './config.js'; +import { createUUID } from './random.js'; var localVideo; var localStream; @@ -113,14 +114,4 @@ function errorHandler(error) { console.log(error); } -// Taken from http://stackoverflow.com/a/105074/515584 -// Strictly speaking, it's not a real UUID, but it gets the job done here -function createUUID() { - function s4() { - return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); - } - - return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); -} - pageReady();