Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about terminating calls with easyProcess #3

Open
killmenot opened this issue Jun 21, 2024 · 1 comment
Open

A question about terminating calls with easyProcess #3

killmenot opened this issue Jun 21, 2024 · 1 comment

Comments

@killmenot
Copy link

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.

  1. incoming CallEvents.Disconnected comes first and I can extract the event data and pass it to my API inside the terminating event
  2. Outgoing CallEvents.Failed with event data comes after I send a request to my API

Screenshot 2024-06-21 at 14 54 52

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:

  1. Is this OK solution? (during my tests it worked OK)
  2. If this solution is good enough, is there any chance to patch the lib?
@NikolasMelui
Copy link
Member

Hi there! Thx for the issue :)
Please take a look at my answer here - #4 (comment)
Your task is "out of scope" of the VoxEngine.easyProcess method, so there is no need to patch the source code.
But in your case the solution you provided is OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants