RTCMultiConnection Docs

RTCMultiConnection API Reference / "token" method

  1. Using "token" method; RTCMultiConnection is setting random user-ids; random session-ids; unique identifiers for file sharing instances etc.
  2. You can use "token" method to get random string.
  3. var randomString = rtcMultiConnection.token();
    rtcMultiConnection.userid = rtcMultiConnection.token();
    
  4. It is defined like this:
    rtcMultiConnection.token = function () {
        // suggested from: https://github.com/muaz-khan/WebRTC-Experiment/issues/154
        if (window.crypto) {
            var a = window.crypto.getRandomValues(new Uint32Array(3)),
                token = '';
            for (var i = 0, l = a.length; i < l; i++) token += a[i].toString(36);
            return token;
        } else {
            return (Math.random() * new Date().getTime()).toString(36).replace(/\./g, '');
        }
    };
    
  5. Default "userid" is generated using "token" method:
  6. rtcMultiConnection.userid = rtcMultiConnection.token();
    


Want to ask a Question?

You can include your email for private conversation!