reject method

Future<void> reject({
  1. String? reason,
  2. bool shouldEmit = true,
})

Reject a call This used to be done by calling hangup, but is a separate method and protocol event as of MSC2746.

Implementation

Future<void> reject({String? reason, bool shouldEmit = true}) async {
  if (state != CallState.kRinging && state != CallState.kFledgling) {
    Logs().e(
        '[VOIP] Call must be in \'ringing|fledgling\' state to reject! (current state was: ${state.toString()}) Calling hangup instead');
    await hangup(reason, shouldEmit);
    return;
  }
  Logs().d('[VOIP] Rejecting call: $callId');
  await terminate(CallParty.kLocal, CallErrorCode.UserHangup, shouldEmit);
  if (shouldEmit) {
    await sendCallReject(
        room, callId, Timeouts.lifetimeMs, localPartyId, reason);
  }
}