From 17efc8b0fb7d3fa66eb8e22f32b81e3e14bcd7f6 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 06 一月 2026 17:37:57 +0800
Subject: [PATCH] 测试完成
---
src/utils/sipService.js | 66 ++++++++++++++++++++++++++-------
1 files changed, 52 insertions(+), 14 deletions(-)
diff --git a/src/utils/sipService.js b/src/utils/sipService.js
index 8f81f71..35ba077 100644
--- a/src/utils/sipService.js
+++ b/src/utils/sipService.js
@@ -1,6 +1,21 @@
import JsSIP from "jssip";
import { Notification, MessageBox, Message, Loading } from "element-ui";
-
+// 鍖婚櫌鏈烘瀯涓嶴IP鏈嶅姟鍣ㄦ槧灏勯厤缃�
+const HOSPITAL_CONFIG = {
+ 涓芥按甯備腑鍖婚櫌: {
+ wsUrl: "wss://192.168.10.124:7443",
+ domain: "192.168.10.124",
+ },
+ 榫欐硥甯備汉姘戝尰闄�: {
+ wsUrl: "wss://10.10.0.220:7443",
+ domain: "10.10.0.220",
+ },
+ // 鍙互缁х画娣诲姞鍏朵粬鍖婚櫌閰嶇疆
+ default: {
+ wsUrl: "wss://192.168.10.124:7443",
+ domain: "192.168.10.124",
+ },
+};
class SipService {
constructor() {
this.ua = null;
@@ -10,17 +25,40 @@
this.onIncomingCall = null;
this.isRegistered = false; // 鏂板娉ㄥ唽鐘舵�佹爣蹇�
this.registrationTime = null; // 鏂板娉ㄥ唽鎴愬姛鏃堕棿鎴�
+ this.currentConfig = null; // 瀛樺偍褰撳墠閰嶇疆
}
-
- init(config) {
+ // 鑾峰彇鍖婚櫌閰嶇疆鏂规硶
+ getHospitalConfig() {
+ const orgName=localStorage.getItem("orgname");
+ return HOSPITAL_CONFIG[orgName] || HOSPITAL_CONFIG.default;
+ }
+ init(baseConfig) {
try {
- this.updateStatus("connecting", "杩炴帴涓�;...");
+ // 鑾峰彇鏈烘瀯鍚嶇О锛屽鏋滄病鏈変紶鍏ュ垯浠巐ocalStorage璇诲彇
+ const orgName = baseConfig.orgName || localStorage.getItem("orgname");
+
+ // 鏍规嵁鏈烘瀯鍚嶇О鑾峰彇瀵瑰簲鐨勬湇鍔″櫒閰嶇疆
+ const hospitalConfig = this.getHospitalConfig(orgName);
+console.log(hospitalConfig,'88');
+
+ // 鍚堝苟閰嶇疆
+ this.currentConfig = {
+ ...baseConfig,
+ ...hospitalConfig,
+ };
+
+ console.log(
+ `褰撳墠鏈烘瀯: ${orgName}, 浣跨敤鏈嶅姟鍣�: ${this.currentConfig.domain}`
+ );
+
+ this.updateStatus("connecting", "杩炴帴涓�...");
+console.log(baseConfig.sipUri,'baseConfig.sipUri');
this.ua = new JsSIP.UA({
- sockets: [new JsSIP.WebSocketInterface(config.wsUrl)],
- uri: config.sipUri,
- password: config.password,
- display_name: config.displayName,
+ sockets: [new JsSIP.WebSocketInterface(this.currentConfig.wsUrl)],
+ uri: baseConfig.sipUri, // 杩欓噷浣跨敤鍩虹鐨剆ipUri锛宒omain閮ㄥ垎浼氳鍔ㄦ�佹浛鎹�
+ password: baseConfig.password,
+ display_name: baseConfig.displayName,
iceServers: [],
register: true,
sessionExpires: 1800,
@@ -78,7 +116,9 @@
const remaining = minDelay - timeSinceRegistration;
return {
canCall: false,
- reason: `娉ㄥ唽鎴愬姛锛岃祫婧愬姞杞戒腑璇风瓑寰� ${Math.ceil(remaining / 1000)} 绉掑悗鍐嶅懠鍙玚,
+ reason: `娉ㄥ唽鎴愬姛锛岃祫婧愬姞杞戒腑璇风瓑寰� ${Math.ceil(
+ remaining / 1000
+ )} 绉掑悗鍐嶅懠鍙玚,
};
}
@@ -99,7 +139,8 @@
if (!this.ua.isRegistered()) {
throw new Error("SIP鏈敞鍐岋紝鏃犳硶鍛煎彨");
}
-
+ const targetUri = `sip:${targetNumber}@${this.currentConfig.domain}`;
+ console.log(`鍛煎彨鐩爣: ${targetUri}`);
const options = {
sessionTimers: true, // 鍚敤浼氳瘽璁℃椂鍣�
sessionTimersExpires: 150,
@@ -122,10 +163,7 @@
},
};
- this.currentSession = this.ua.call(
- `sip:${targetNumber}@192.168.10.124`,
- options
- );
+ this.currentSession = this.ua.call(targetUri, options);
this.setupPeerConnection(this.currentSession);
this.setupAudio(this.currentSession);
--
Gitblit v1.9.3