You can just invokeAfter clicking the URL click-to-call-min.js can automatically make call without clicking the button. How to do?
call()
from connect()
as follows:function init_page(){
Flashphoner.init({});
localAudio = document.getElementById("localAudio");
remoteAudio = document.getElementById("remoteAudio");
connect();
}
function connect() {
var url = "wss://wcs_address:8443"
var sipOptions = {
registerRequired: true
};
var connectionOptions = {
urlServer: url,
sipOptions: sipOptions
};
console.log("Create new session with url " + url);
Flashphoner.createSession(connectionOptions).on(SESSION_STATUS.ESTABLISHED, function (session) {
console.log(SESSION_STATUS.ESTABLISHED);
}).on(SESSION_STATUS.REGISTERED, function (session) {
console.log(SESSION_STATUS.REGISTERED);
});
call(); /// Here we replaced callBtn.onclick = call by direct call() invokation
}
function call(session) {
...
}
11:26:04 INFO webrtc - Initialized
flashphoner.js:14045 11:26:04 INFO websocket - Initialized
flashphoner.js:14045 11:26:04 INFO core - Initialized
click-to-call-min.js:51 Create new session with url wss://wss_address:8443
flashphoner.js:14045 11:26:04 INFO core - Status is PENDING
flashphoner.js:11111 Uncaught Error: Invalid session state
at Object.createCall (flashphoner.js:11111)
at call (click-to-call-min.js:68)
at connect (click-to-call-min.js:58)
at init_page (click-to-call-min.js:37)
at onload (?callee=08619022:40)
createCall @ flashphoner.js:11111
call @ click-to-call-min.js:68
connect @ click-to-call-min.js:58
init_page @ click-to-call-min.js:37
onload @ ?callee=08619022:40
click-to-call-min.js:53 ESTABLISHED
click-to-call-min.js:55 REGISTERED
call()
should be invoked only when session is established and registered successfully:Flashphoner.createSession(connectionOptions).on(SESSION_STATUS.ESTABLISHED, function (session) {
console.log(SESSION_STATUS.ESTABLISHED);
}).on(SESSION_STATUS.REGISTERED, function (session) {
console.log(SESSION_STATUS.REGISTERED);
call(); /// Please move call() here
});