WXL (wul)
昨天 2977b13162d90304d972d4b04be8c4adc1250b93
src/utils/sipService.js
@@ -30,10 +30,11 @@
      this.ua.start();
      // 事件监听
     // 事件监听
      this.ua.on("registered", () => {
        this.isRegistered = true;
        this.registrationTime = Date.now(); // 记录注册成功时间
        console.log(this.registrationTime, "注册时间");
        this.updateStatus("registered", "已注册");
      });
@@ -44,6 +45,8 @@
      this.ua.on("unregistered", () => {
        this.isRegistered = false;
        let registrationTime = Date.now(); // 记录注销成功时间
        console.log(registrationTime, "注销时间");
        this.updateStatus("disconnected", "已注销");
      });
      this.ua.on("disconnected", () =>
@@ -61,7 +64,7 @@
      throw error;
    }
  }
// 新增方法:检查是否可以呼叫
  // 新增方法:检查是否可以呼叫
  canMakeCall(minDelay = 2000) {
    if (!this.isRegistered) {
      return { canCall: false, reason: "SIP未注册,无法呼叫" };
@@ -74,7 +77,7 @@
      const remaining = minDelay - timeSinceRegistration;
      return {
        canCall: false,
        reason: `注册成功,请等待 ${Math.ceil(remaining / 1000)} 秒后再呼叫`
        reason: `注册成功,请等待 ${Math.ceil(remaining / 1000)} 秒后再呼叫`,
      };
    }
@@ -118,7 +121,7 @@
        };
        this.currentSession = this.ua.call(
          `sip:${targetNumber}@192.169.129.198`,
          `sip:${targetNumber}@192.168.10.124`,
          options
        );
@@ -199,7 +202,7 @@
        errorMessage = "会话参数不满足服务器要求";
        break;
      default:
        errorMessage = `呼叫失败: ${e.cause || e.message}`;
        errorMessage = `呼叫失败3: ${e.cause || e.message}`;
    }
    this.updateCallStatus("failed55", errorMessage);