| | |
| | | }, |
| | | }, |
| | | mounted() { |
| | | console.log('当前分机号',this.sipConfig); |
| | | console.log("当前分机号", this.sipConfig); |
| | | |
| | | sipService.init(this.sipConfig); |
| | | sipService.onStatusChange = (status) => { |
| | |
| | | } |
| | | this.callStatus = "calling"; |
| | | this.isCalling = true; |
| | | console.log('开始呼叫:',sipService); |
| | | console.log("开始呼叫:", sipService); |
| | | |
| | | await sipService.makeCall(this.phoneNumber); |
| | | } catch (error) { |
| | | console.error("呼叫失败:", error); |
| | | let registrationTime = Date.now(); // 记录注销成功时间 |
| | | console.log(registrationTime, "呼叫失败时间"); |
| | | console.error("呼叫失败1:", error); |
| | | this.callStatus = "ended"; |
| | | this.isCalling = false; |
| | | this.$message.error(`呼叫失败: ${error.message}`); |
| | |
| | | this.ua.start(); |
| | | |
| | | // 事件监听 |
| | | // 事件监听 |
| | | this.ua.on("registered", () => { |
| | | this.isRegistered = true; |
| | | this.registrationTime = Date.now(); // 记录注册成功时间 |
| | | console.log(this.registrationTime, "注册时间"); |
| | | |
| | | this.updateStatus("registered", "已注册"); |
| | | }); |
| | | |
| | |
| | | |
| | | this.ua.on("unregistered", () => { |
| | | this.isRegistered = false; |
| | | let registrationTime = Date.now(); // 记录注销成功时间 |
| | | console.log(registrationTime, "注销时间"); |
| | | this.updateStatus("disconnected", "已注销"); |
| | | }); |
| | | this.ua.on("disconnected", () => |
| | |
| | | const remaining = minDelay - timeSinceRegistration; |
| | | return { |
| | | canCall: false, |
| | | reason: `注册成功,请等待 ${Math.ceil(remaining / 1000)} 秒后再呼叫` |
| | | reason: `注册成功,请等待 ${Math.ceil(remaining / 1000)} 秒后再呼叫`, |
| | | }; |
| | | } |
| | | |
| | |
| | | errorMessage = "会话参数不满足服务器要求"; |
| | | break; |
| | | default: |
| | | errorMessage = `呼叫失败: ${e.cause || e.message}`; |
| | | errorMessage = `呼叫失败3: ${e.cause || e.message}`; |
| | | } |
| | | |
| | | this.updateCallStatus("failed55", errorMessage); |