↑ WEBRTC EXPERIMENTS

Manual session establishment + extra data transmission

Copyright © Muaz Khan <@muazkh >.

This demo is out-dated i.e. deprecated (written in 2013).

Please try other demos: https://github.com/muaz-khan/RTCMultiConnection

New Session:

Text Chat

Share Files



Go ahead and try!

Pass "session-id" only-over the constructor:

var connection = new RTCMultiConnection('session-id');

When calling "open" method; pass an argument like this:

connection.open({ 
    // "extra" object allows you pass extra data like username, number of participants etc. 
    extra: { 
        boolean: true, 
        integer: 0123456789, 
        array: [], 
        object: {} 
    }, 

    // it is the broadcasting interval — default value is 3 seconds 
    interval: 3000 
});

Use "onNewSession" method to show each new session in a list so end users can manually join any session they prefer:

connection.onNewSession = function(session) { 
    // use "session.extra" to access "extra" data 
};

To manually join a preferred session any time; use "join" method instead of "connect" method:

connection.join(session, extra); // e.g. string 
connection.join(session, 'username'); // e.g. object 
connection.join(session, { username: 'mine user name' });

"extra" data can be accessed using "connection.onopen" method:

connection.onopen = function(extra){ 
    console.log('Data Connection is opened between you and ', extra.username); 
};


RTCMultiConnection v1.2

<script src="https://cdn.webrtc-experiment.com/RTCMultiConnection.js"></script>


Feedback