twilio / twilio-voice.js

Twilio's JavaScript Voice SDK
Other
50 stars 53 forks source link

[BUG] `device.calls` is always an empty array #96

Closed francoisl closed 2 years ago

francoisl commented 2 years ago

Code to reproduce the issue:

const device = new Device(token);

// Make an ougoing call
device.connect({ params: { To: phoneNumber } } );

console.log(device.calls);

// Prints: 
// []

The issue is also reproducible when using await:

await device.connect({ params: { To: phoneNumber } } );

console.log(device.calls);

// Prints: 
// []

Expected behavior: As stated in the documentation, device.calls should contain an instance of a Call, representing the outgoing call

console.log(device.calls);
// [Call]

Actual behavior:

device.calls is always an empty array.

It appears that the connect function never adds the new activeCall to its internal this._calls list.

Software versions:

mhuynh5757 commented 2 years ago

Hi @francoisl, this is expected behavior in the 2.x versions of the SDK (changed from 1.x) such that device.activeCall is no longer part of the device.calls array member. Please see the updated documentation: https://www.twilio.com/docs/voice/sdks/javascript/twiliodevice#devicecalls

waynebrantley commented 2 years ago

@mhuynh5757 I am not following. The link you sent says that 'calls' is a list of calls the device instance is maintaining. If a call is in progress it seems that would be in the calls array - as it is maintaining it.

What else would be in the calls array?