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.