My use case is that if two calls are initiated for the same client ID at the same time, I don’t want the client’s device to ring twice. The mobile device should only connect with one call, and the other call should be routed to a different phone number.
I am initiating a conference call and adding participants to the conference. Before adding a participant, I check their status as follows:
$callsQueued = $twilio->calls->read([
'to' => 'client:' . $driver,
'status' => 'queued'
]);
$callsRinging = $twilio->calls->read([
'to' => 'client:' . $driver,
'status' => 'ringing'
]);
$callsInProgress = $twilio->calls->read([
'to' => 'client:' . $driver,
'status' => 'in-progress'
]);
if (count($callsqueued)>1||count($callsRinging)>1 || count ($callsinProgress)>1 ){
call to manual phone number
continue;
}
else {
adding driver into conference
}
Here, $driver = 235242 refers to the mobile app client ID.
These checks when 2nd call started after a while
The issue arises when two calls are started at the same time. In such cases, $callsQueued = [], $callsRinging = [], and $callsInProgress = [].
How can I prevent this behaviour? I don’t want the client’s device to ring twice."
You need to sign in to view this answers
Leave feedback about this