hangup method

Future<void> hangup(
  1. String callId
)

Implementation

Future<void> hangup(String callId) async {
  if (model.curCall?.callId == callId) {
    clearAllTimer();
    if (model.state == ChatCallKitCallState.answering) {
      handler.onCallEndReason(callId, ChatCallKitCallEndReason.hangup);
    } else if (model.state == ChatCallKitCallState.outgoing) {
      sendCancelCallMsgToCallee(
        model.curCall!.remoteUserAccount!,
        model.curCall!.callId,
      );
      handler.onCallEndReason(callId, ChatCallKitCallEndReason.cancel);
    } else if (model.state == ChatCallKitCallState.alerting) {
      sendAnswerMsg(
        model.curCall!.remoteUserAccount!,
        model.curCall!.callId,
        kRefuseResult,
        model.curCall!.remoteCallDevId!,
      );
      handler.onCallEndReason(callId, ChatCallKitCallEndReason.refuse);
    }
    model.state = ChatCallKitCallState.idle;
  }
}