WebRTC Start from Scratch

See "Start from Scratch" section on this web page http://bit.ly/BYCTWD-WebRTC-activity

by Chris Vitalos

HTML

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>
<!-- WebRTC Start from Scratch -->
<button id="btn-open-room">Open Room</button>
<button id="btn-join-room">Join Room</button><hr>

JavaScript

var connection = new RTCMultiConnection();

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

// all below lines are optional; however recommended.

connection.session = {
    audio: true,
    video: true
};

connection.sdpConstraints.mandatory = {
    OfferToReceiveAudio: true,
    OfferToReceiveVideo: true
};

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

// Assign the predefinedRoomId variable (below) to your name //

var predefinedRoomId = 'Chris_V';

document.getElementById('btn-open-room').onclick = function() {
    this.disabled = true;
    connection.open( predefinedRoomId );
};

document.getElementById('btn-join-room').onclick = function() {
    this.disabled = true;
    connection.join( predefinedRoomId );
};