So here I want to use supervision calls to find out the conversation that happens between client_call and operator_call in the same scenario. I'm a bit confused on how to capture multiple calls in the same scenario between supervisor_call and operator_call and client_call.
Here is the code in my scenario.
Any help or pointers would be greatly appreciated.
require(Modules.Conference);
const voice = VoiceList.Google.id_ID_Standard_C;
var client_call;
var operator_call;
var supervisor_call;
let conf;
VoxEngine.addEventListener(AppEvents.CallAlerting, e => {
client_call = e.call;
let dest = e.destination.split("#");
if(e.callerid != "supervisor") {
if(isNaN(dest[1])) {
operator_call = VoxEngine.callUser({
username: dest[1],
callerid: e.callerid,
displayName: e.displayName,
video: false,
scheme: e.scheme
});
} else {
operator_call = VoxEngine.callSIP("sip:"+dest[1]+"@sip2.b3networks.com",
{
"callerid": e.callerid,
"regId": 859,
});
}
} else {
supervisor_call({"callerid":e.callerid,"destination":dest[1],"displayname":e.displayName,"scheme":e.scheme});
}
VoxEngine.easyProcess(client_call, operator_call, () => {});
operator_call.addEventListener(CallEvents.Connected, callConnected);
operator_call.addEventListener(CallEvents.Disconnected, callDisconnected);
operator_call.addEventListener(CallEvents.Failed, callFailed);
});
function playbackFinished(e) {
client_call.answer();
VoxEngine.sendMediaBetween(client_call, operator_call);
VoxEngine.removeEventListener(CallEvents.PlaybackFinished);
}
function callConnected() {
operator_call.say("Halo, panggilan ini percobaan dari Askarasoft Indonesia", voice);
operator_call.addEventListener(CallEvents.PlaybackFinished, playbackFinished);
}
function callDisconnected() {
operator_call.hangup();
client_call.hangup();
VoxEngine.terminate();
}
function callFailed() {
// any additional attemp if call fails
client_call.hangup();
operator_call.hangup();
VoxEngine.terminate();
}
function supervisor_call(params) {
if(isNaN(params.destination)) {
supervisor_call = VoxEngine.callUser(
{
username: params.destination,
callerid: params.callerid,
displayName: params.displayName,
video: false,
scheme: params.scheme
}
);
} else {
supervisor_call = VoxEngine.callSIP("sip:"+params.destination+"@sip2.b3networks.com",
{
"callerid": params.callerid,
"regId": 859,
});
}
conf = VoxEngine.createConference();
supervisor_call.addEventListener(CallEvents.Disconnected, supervisor_call_disconnected);
supervisor_call.addEventListener(CallEvents.Failed, supervisor_call_failed);
client_call.sendMediaTo(conf);
operator_call.sendMediaTo(conf);
conf.sendMediaTo(supervisor_call);
VoxEngine.sendMediaBetween(client_call, operator_call);
}
function supervisor_call_disconnected() {
VoxEngine.sendMediaBetween(client_call, operator_call);
VoxEngine.destroyConference(conf);
}
function supervisor_call_failed() {
VoxEngine.sendMediaBetween(client_call, operator_call);
VoxEngine.destroyConference(conf);
}
I want to use supervision calls to find out the conversation that happens between client_call and operator_call and capture multiple calls in the same scenario.
By multiple calls, I mean that one scenario can be used for both regular calls and supervision calls.