MenuMenu

RTCMultiConnection.extra

Share extra information with all connected users

"event.extra" is accessible from all events e.g. onopen onmessage onstream onExtraDataUpdated etc.

Usage

connection.extra = {
    fullName: 'Your full name',
    email: 'Your email',
    photo: 'http://site.com/profile.png'
};

connection.openOrJoin('the-room-id');

Description

parameterdescription
extra it is a javascript object which accepts any kind of value
it can be a string
it can be a number
it can be a boolean
it can be a javascript object
etc.
connection.extra = {
    username: 'muazkh',
    fullname: 'Muaz Khan',
    email: 'muazkh@gmail.com',
    boolean: true,
    integer: 123,
    objects: {},
    whatever: 'whatever'
};

Video presentation

Update extra data

connection.extra.modifiedValue = 'new value';
connection.updateExtraData();

connection.onExtraDataUpdated = function(event) {
    var modifiedValue = event.extra.modifiedValue;
    var whoModified = event.userid; // or event.extra.fullName
};

Please check this for more information: updateExtraData

Demo

<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
};

connection.extra = {
    joinedAt: (new Date).toISOString()
};

connection.onstream = function(event) {
    document.body.appendChild(event.mediaElement);
    if (event.type === 'remote') {
        var heJoinedAt = new Date(event.extra.joinedAt).getTime();
        var currentDate = new Date().getTime();
        var latency = currentDate - heJoinedAt;
    }
};

connection.openOrJoin('your-room-id');
</script>