invite method

Future<void> invite(
  1. CallDestination dest
)

Initiate new outgoing call via sending INVITE request (creates new call instance, adds it to list, notifies UI)

Implementation

Future<void> invite(CallDestination dest) async {
  _logs?.print('Trying to invite ${dest.toExt} from account:${dest.fromAccId}');
  try {
    int callId = await SiprixVoipSdk().invite(dest) ?? 0;

    String accUri       = _accountsModel.getUri(dest.fromAccId);
    bool hasSecureMedia = _accountsModel.hasSecureMedia(dest.fromAccId);

    CallModel newCall = CallModel(callId, accUri, dest.toExt, false, hasSecureMedia, dest.withVideo, _logs);
    _callItems.add(newCall);
    _cdrs?.add(newCall);
    _postResolveContactName(newCall);
    _logs?.print('Added new call $callId');

    if(_switchedCallId == kEmptyCallId) {
       _switchedCallId = callId;
    }

    notifyListeners();

  } on PlatformException catch (err) {
    _logs?.print('Can\'t invite Err: ${err.code} ${err.message}');
    return Future.error((err.message==null) ? err.code : err.message!);
  }
}