call method

Future<VICall> call(
  1. String number, {
  2. VICallSettings? settings,
})

Creates a new VICall instance and starts the outgoing call.

number - The call destination that might be Voximplant username, phone number or SIP URI. Actual routing is then performed by a VoxEngine scenario.

Optional settings - Additional call parameters like video direction for the call, preferred video codec, custom data.

Throws VIException, if the client is not logged in, otherwise returns VICall instance.

Errors:

Implementation

Future<VICall> call(String number, {VICallSettings? settings}) async {
  try {
    if (settings == null) {
      settings = VICallSettings();
    }
    Map<String, dynamic>? data = await _channel
        .invokeMapMethod<String, dynamic>('Client.call', <String, dynamic>{
      'number': number,
      'sendVideo': settings.videoFlags.sendVideo,
      'receiveVideo': settings.videoFlags.receiveVideo,
      'videoCodec': settings.preferredVideoCodec.toString(),
      'customData': settings.customData,
      'extraHeaders': settings.extraHeaders,
      'conference': false,
    });
    if (data == null) {
      _VILog._e('VIClient: call: data was null, skipping');
      throw VIException(
        VIClientError.ERROR_INTERNAL,
        'VIClient:call: data was null',
      );
    }
    VICall call = VICall._(data['callId'], _channel);
    return call;
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}