VoxEngine.forwardCallToUserDirect();
VoxEngine.forwardCallToUser(null, true);
, but in this case calls will cost money. var call1, call2; VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) { call1 = e.call; call2 = VoxEngine.callUserDirect(e.call, e.destination, e.displayName, e.headers); call2.addEventListener(CallEvents.Connected, handleCallConnected); }); function handleCallConnected(e) { call1.answerDirect(call2); // , , - setTimeout(VoxEngine.terminate, 5000); }
// SDK <script type="text/javascript" src="//cdn.voximplant.com/edge/voximplant.min.js"></script> // HTML function log(str) { document.getElementById("log").innerHTML += str+"<br/>"; } // VoxImplant var voxAPI = VoxImplant.getInstance(); // voxAPI.on(VoxImplant.Events.SDKReady, onSdkReady); voxAPI.on(VoxImplant.Events.ConnectionEstablished, onConnectionEstablished); voxAPI.on(VoxImplant.Events.ConnectionFailed, onConnectionFailed); voxAPI.on(VoxImplant.Events.ConnectionClosed, onConnectionClosed); voxAPI.on(VoxImplant.Events.AuthResult, onAuthResult); voxAPI.v(VoxImplant.Events.IncomingCall, onIncomingCall); voxAPI.on(VoxImplant.Events.MicAccessResult, onMicAccessResult); // SDK try { voxAPI.init({ micRequired: true, // / VoxImplant videoSupport: true // }); } catch(e) { // , log(e.message); } // SDK - function onSdkReady(){ voxAPI.connect(); // / } // function onMicAccessResult(e) { if (e.result) { // / } else { // / } } // VoxImplant function onConnectionEstablished() { // - , // application_user, application_name, account_name application_user_password voxAPI.login(application_user+"@"+application_name+"."+account_name+".voximplant.com", application_user_password); } // VoxImplant function onConnectionFailed() { // - UDP } // function onConnectionClosed() { // connect } function onAuthResult(e) { if (e.result) { // - } else { // , e.code, } } var currentCall = null; // // function onIncomingCall(e) { currentCall = e.call; // currentCall.on(VoxImplant.CallEvents.Connected, onCallConnected); currentCall.on(VoxImplant.CallEvents.Disconnected, onCallDisconnected); currentCall.on(VoxImplant.CallEvents.Failed, onCallFailed); // . . currentCall.answer(null, {}, { receiveVideo: true, sendVideo: true }); } // function createCall() { // application_username - , ( ) currentCall = voxAPI.call(application_username, { receiveVideo: true, sendVideo: true }, "TEST CUSTOM DATA", {"X-DirectCall": "true"}); // currentCall.on(VoxImplant.CallEvents.Connected, onCallConnected); currentCall.on(VoxImplant.CallEvents.Disconnected, onCallDisconnected); currentCall.on(VoxImplant.CallEvents.Failed, onCallFailed); } // function onCallConnected(e) { // voxAPI.sendVideo(true); currentCall.showRemoteVideo(true); } // function onCallDisconnected(e) { currentCall = null; } // function onCallFailed(e) { // e.code, e.reason }
Source: https://habr.com/ru/post/231383/
All Articles