onRejectReceived method

Future<void> onRejectReceived(
  1. CallErrorCode? reason
)

Implementation

Future<void> onRejectReceived(CallErrorCode? reason) async {
  Logs().v('[VOIP] Reject received for call ID $callId');
  // No need to check party_id for reject because if we'd received either
  // an answer or reject, we wouldn't be in state InviteSent
  final shouldTerminate = (state == CallState.kFledgling &&
          direction == CallDirection.kIncoming) ||
      CallState.kInviteSent == state ||
      CallState.kRinging == state;

  if (shouldTerminate) {
    await terminate(
        CallParty.kRemote, reason ?? CallErrorCode.userHangup, true);
  } else {
    Logs().e('[VOIP] Call is in state: ${state.toString()}: ignoring reject');
  }
}