muaz-khan / WebRTC-Experiment

WebRTC, WebRTC and WebRTC. Everything here is all about WebRTC!!
https://www.webrtc-experiment.com/
MIT License
11.74k stars 3.95k forks source link

password protecting the conference room #123

Open altanai opened 10 years ago

altanai commented 10 years ago

I am trying to password protect the multi party conference room joining , however session ceases to exist if url is redirected or any additional parameters such as memeber name or meeting id is added to the existsing url of created conference .

muaz-khan commented 10 years ago

Try following demo using RTCMultiConnection.js:

<h1>RTCMultiConnection & Password Protected Conferencing</h1>
<button id="setup">Setup RTC-Multi-Connection</button><hr />

<script src="https://www.webrtc-experiment.com/RTCMultiConnection-v1.4.js"></script>
<script src="https://www.webrtc-experiment.com/firebase.js"></script>
<script>
document.querySelector('#setup').onclick = function () {
    // room password has been set before calling "open" method
    connection.extra.password = 'valid-password';
    connection.open();
    this.disabled = true;
};

var connection = new RTCMultiConnection();
connection.onNewSession = function (session) {
    // set password for person who is trying to join the room
    connection.extra.password = 'wrong-password';
    connection.join(session);
};

connection.onRequest = function (userid, extra) {
    // validating password in "onRequest"
    if (extra.password != connection.extra.password)
        throw 'password: ' + extra.password + ' !== ' + connection.extra.password;

    connection.accept(userid, extra);
};

connection.onstream = function (e) {
    document.body.appendChild(e.mediaElement);
};

connection.connect();

window.skipRTCMultiConnectionLogs = true;
</script>
<style>html {background: rgb(255, 252, 239);}audio,video {width:40%;vertical-align:top;}</style>
  1. onRequest allows you verify incoming participation requests.
  2. You can pass passwords as Extra Data.
  3. onNewSession allows you set password for users who are trying to join conferencing room.

For initiator, you can set extra object before calling open method:

connection.extra.password = 'room-password';
connection.open();
SalvatoreAD commented 7 years ago

HI , Ca I use this code for RTCMulticonnection v3?