muaz-khan / WebRTC-Experiment

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

Is there any way to have the same room always open for users to join? #493

Open axoivs opened 7 years ago

axoivs commented 7 years ago

I was looking to add a permanent user to the many to many audio conference demo. That way everyone will connect to the same room automatically when the users join. I think the randomly generated rooms is a great feature but I'm wondering how you can make the application open only one single room where everyone can connect and interact?

muaz-khan commented 7 years ago

Try following code on all pages:

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>

<script>
var connection = new RTCMultiConnection();

// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

// if you want audio+video conferencing
connection.session = {
    audio: true,
    video: true
};

// do NOT change room-id below
// keep it same on all pages
connection.openOrJoin('single-room-for-all-pages');
</script>

For newbies: