onRTCError method

void onRTCError(
  1. ErrorCodeType err,
  2. String desc
)

Implementation

void onRTCError(ErrorCodeType err, String desc) {
  if (err == ErrorCodeType.errTokenExpired ||
      err == ErrorCodeType.errInvalidToken ||
      err == ErrorCodeType.errFailed) {
    for (var value in handlers) {
      if (err == ErrorCodeType.errTokenExpired) {
        value.onError.call(ChatCallKitError.rtc(err.index, "Token expired"));
      } else if (err == ErrorCodeType.errInvalidToken) {
        value.onError.call(ChatCallKitError.rtc(err.index, "Invalid token"));
      } else {
        value.onError.call(ChatCallKitError.rtc(err.index,
            "General error with no classified reason. Try calling the method again"));
      }
    }
  } else {
    if (err == ErrorCodeType.errFailed) {
      for (var value in handlers) {
        value.onError.call(ChatCallKitError.rtc(
            ChatCallKitErrorProcessCode.general,
            "General error with no classified reason. Try calling the method again"));
      }
    }

    for (var value in handlers) {
      value.onCallEnd
          .call(_chat.model.curCall?.callId, ChatCallKitCallEndReason.err);
    }
  }
  _chat.clearInfo();
}