onopen | RTCMultiConnection

This event is fired as soon as WebRTC data channel opens.

Usage

connection.onopen = function(event) {
    var remoteUserId = event.userid;
    var remoteUserFullName = event.extra.fullName;

    alert('data connection opened with ' + remoteUserFullName);
};

Description

parameterdescription
userid data connection opened with this user-id
connection.onopen = function(event) {
    var remoteUserId = event.userid;
};
extra extra information
connection.onopen = function(event) {
    var remoteUserFullName = event.extra.fullName;
};

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 text chat
connection.session = {
    data: true
};

connection.onopen = function(event) {
    connection.send('hello everyone');
};

connection.onmessage = function(event) {
    alert(event.userid + ' said: ' + event.data);
};

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