0

I have this code that creates a button for every user that is logged into my WebRTC page. When clicked this button allows two users to view each other (VideoChat).

function connect()
{
    easyrtc.setVideoDims(720,720);
    easyrtc.enableDebug(false);
    easyrtc.setRoomOccupantListener(convertListToButtons);
    easyrtc.easyApp("easyrtc.videoChatHd", "selfVideo", ["callerVideo"], loginSuccess, loginFailure);
    easyrtc.setUserName('user1');
}

function convertListToButtons (roomName, data, isPrimary)
{
    clearConnectList();
    var otherClientDiv = document.getElementById('otherClients');

    for(var easyrtcid in data)
    {        
        var button = document.createElement('button');
        button.onclick = function(easyrtcid)
        {
            return function()
            {
                performCall(easyrtcid);
            };
        }(easyrtcid);

        var label = document.createTextNode(easyrtc.idToName(easyrtcid));
        button.appendChild(label);
        button.className = "callbutton";
        otherClientDiv.appendChild(button);
    }
}

I am trying to avoid having that button and using my database to determine who connects to who automatically.

The database looks like this:

User(macAddress, otherUserMac)

Since the easyrtcid is generated at random, how can I set the easyrtcid to the value I will read from the database? I tried setting the username but that didn't help. Or maybe there is an easier way, I do have the user's mac address, but it seems that I can't check that again in JavaScript.

J_Strauton
  • 2,270
  • 3
  • 28
  • 70

1 Answers1

0

The easyrtc API does not allow you to set your own easyrtcid value, so your best option is to use that Id to update a user object, and use those user objects to perform the calls automatically.

  1. Get easyRTCId
  2. Push that Id to the other User (or have them poll for it, etc)
    • You could push this into a database and poll for it, push over websocket, anything
  3. When the other User gets the first User's easyrtcid, make the call automatically
xdumaine
  • 10,096
  • 6
  • 62
  • 103