Skip to content

A question about terminating calls with easyProcess #3

Description

@killmenot

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions