Hello,
During the testing my app I found a problem with easyprocess. Let me describe it.
The purpose of my app is to accept the incoming call from one phone number (phone-number-1
) to vox phone number (vox-phone-number
) and to connect this call with another phone number (phone-number-2
), so:
incoming call: phone-number-1
-> vox-phone-number
outgoing call: vox-phone-number
-> phone-number-2
The VoxEngine.easyProcess(incomingCall, outgoingCall)
works fine until I need to collect the information from both calls. The screenshot below shows the log output when phone-number-1
hangup the outgoing call.
- incoming CallEvents.Disconnected comes first and I can extract the event data and pass it to my API inside the terminating event
- Outgoing CallEvents.Failed with event data comes after I send a request to my API
![Screenshot 2024-06-21 at 14 54 52](https://private-user-images.githubusercontent.com/119337/341784981-9cb99f15-2afc-4bca-98df-5939c401832b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk5Mzc2MTIsIm5iZiI6MTcxOTkzNzMxMiwicGF0aCI6Ii8xMTkzMzcvMzQxNzg0OTgxLTljYjk5ZjE1LTJhZmMtNGJjYS05OGRmLTU5MzljNDAxODMyYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwMlQxNjIxNTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lMmMzMzYzOWQxMWM0ZTE5NTJlNDc2YmRhZTU4NWVkZDdmNGI0OGFiMDBkOTEwYTU0OGY2YzAyNzBkYjU3MmI3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.cre5axfgoiupsei5JdmOo6zZC8ITJG-V4SWjE9Qs9hk)
NOTE: If I hangup phone-number-2
, then I will be able to get outgoing event data but incoming event data comes after the terminating event
During the investigation I got the desired behavior, instead the following code
const defaultHangupHandler = (e) => {
JSession.close();
};
...
call1.addEventListener(CallEvents.Failed, defaultHangupHandler);
call1.addEventListener(CallEvents.Disconnected, defaultHangupHandler);
call2.addEventListener(CallEvents.Failed, defaultHangupHandler);
call2.addEventListener(CallEvents.Disconnected, defaultHangupHandler);
I use the following
let finished1 = false;
let finished2 = false;
const terminate = () => {
if (finished1 && finished2) {
VoxEngine.terminate()
}
}
const call1HangupHandler = (e) => {
finished1 = true;
call2.hangup();
terminate();
}
const call2HangupHandler = (e) => {
finished2 = true;
call1.hangup();
terminate();
}
call1.addEventListener(CallEvents.Failed, call1HangupHandler);
call1.addEventListener(CallEvents.Disconnected, call1HangupHandler);
call2.addEventListener(CallEvents.Failed, call2HangupHandler);
call2.addEventListener(CallEvents.Disconnected, call2HangupHandler);
The questions I have are pretty simple:
- Is this OK solution? (during my tests it worked OK)
- If this solution is good enough, is there any chance to patch the lib?