How to remove "Call" button and make call autometically?

44 views
Skip to first unread message

Victor Denisenko

unread,
Aug 5, 2018, 3:50:00 AM8/5/18
to EasyRTC
I need to use credentials and to call using the same button that I click after enter credentials. But in the easyRTS all the examples has button  button.onclick = function() {....}. This second button that I need to press. How to remove this button and make call automatically after I enter credentials and press the first button?
My modified fragment of code (without credenrials) now is: 
var selfEasyrtcid = "";

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

function clearConnectList() {
    var otherClientDiv = document.getElementById('otherClients');
    while (otherClientDiv.hasChildNodes()) {
        otherClientDiv.removeChild(otherClientDiv.lastChild);
    }
}

function convertListToButtons(roomName, data, isPrimary) {
    for (var easyrtcid in data) {
        performCall(easyrtcid);
    }
}

function performCall(otherEasyrtcid) {
    easyrtc.hangupAll();
    var acceptedCB = function(accepted, caller) {
        if( !accepted ) {
            easyrtc.showError("CALL-REJECTED", "Sorry, your call to " + easyrtc.idToName(caller) + " was rejected");
        }
    };
    var successCB = function() {};
    var failureCB = function () { };
    easyrtc.call(otherEasyrtcid, successCB, failureCB, acceptedCB);
}

function loginSuccess(easyrtcid) {
    selfEasyrtcid = easyrtcid;
    document.getElementById("iam").innerHTML = "I am " + easyrtc.cleanId(easyrtcid);
    
}

function loginFailure(errorCode, message) {
    easyrtc.showError(errorCode, message);
}

easyrtc.setAcceptChecker(function(caller, cb) {
    cb(true);
} );


But this code allow to get the client video only in case when I set breakpoint in function loginSuccess(easyrtcid)
and in 
easyrtc.call(...) function and debug it in Chrome browser by stepping. If I launch code in Chrome without breakpoint I don't see client video. It means that there are must be delay after client enters server and it starts to call. In easyrts exemples this delay is made by button that must be clicked manually. How the remove that button and make call automatically? 


Reply all
Reply to author
Forward
0 new messages