ue-softphone-sdk 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +1 -1
- package/Dockerfile +7 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/ue-softphone-sdk.js +2 -2
- package/package.json +1 -1
- package/sdkdemo/hangup.wav +0 -0
- package/sdkdemo/ring.wav +0 -0
- package/sdkdemo/ue-load.min.js +116 -0
- package/sdkdemo/ue.global.js +15361 -0
- package/sdkdemo/ue.lib.css +1 -0
- package/sdkdemo/ue.min.js +41 -0
- package/src/config.ts +6 -0
- package/src/index.ts +70 -10
package/src/config.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: cuixuecheng
|
|
3
3
|
* @Date: 2023-02-21 18:40:21
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime: 2023-
|
|
4
|
+
* @LastEditors: Wangtao
|
|
5
|
+
* @LastEditTime: 2023-11-01 18:47:30
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -79,6 +79,8 @@ interface DialoutParams {
|
|
|
79
79
|
extras?: any;
|
|
80
80
|
success?: Function;
|
|
81
81
|
fail?: Function;
|
|
82
|
+
numberGroupId?: String;
|
|
83
|
+
numberGroupName?: String;
|
|
82
84
|
// group?: string;
|
|
83
85
|
// groupRule?: Number;
|
|
84
86
|
// groupareaCode?: String;
|
|
@@ -235,6 +237,7 @@ export default class ueSoftphone {
|
|
|
235
237
|
static callApiUrl: String = "https://app.useasy.cn/api";
|
|
236
238
|
static agentextras: any;
|
|
237
239
|
static Socketinstance: any = null;
|
|
240
|
+
static AudioTask: any = null
|
|
238
241
|
// static MonitorSocketinstance: any = null;
|
|
239
242
|
static noop(): void {}
|
|
240
243
|
static debug: (msg: any) => void;
|
|
@@ -346,6 +349,7 @@ export default class ueSoftphone {
|
|
|
346
349
|
audioObj = (await this.openMediaAudio("请打开麦克风权限!", isStrongHint)) || {};
|
|
347
350
|
} catch (error) {
|
|
348
351
|
console.log(error);
|
|
352
|
+
console.log('授权失败================================')
|
|
349
353
|
}
|
|
350
354
|
}
|
|
351
355
|
if (options.password) {
|
|
@@ -537,6 +541,19 @@ export default class ueSoftphone {
|
|
|
537
541
|
subtype: event.subType,
|
|
538
542
|
data: event.data
|
|
539
543
|
});
|
|
544
|
+
|
|
545
|
+
if (ueSoftphone.initOptions.loginType === "WEBRTC") {
|
|
546
|
+
if (event.data && event.data.callType && event.data.callType === 'callin' && event.data.eventType && event.data.eventType ==='ring') {
|
|
547
|
+
if (!ueSoftphone.AudioTask) {
|
|
548
|
+
ueSoftphone.AudioTask = new AudioTask('https://softphone.useasy.cn/ring.wav');
|
|
549
|
+
}
|
|
550
|
+
ueSoftphone.AudioTask.ringAudioPlay()
|
|
551
|
+
} else {
|
|
552
|
+
if (ueSoftphone.AudioTask) {
|
|
553
|
+
ueSoftphone.AudioTask.ringAudioPause()
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
540
557
|
if (fn && typeof fn === "function") {
|
|
541
558
|
fn("success");
|
|
542
559
|
}
|
|
@@ -864,6 +881,17 @@ export default class ueSoftphone {
|
|
|
864
881
|
});
|
|
865
882
|
return;
|
|
866
883
|
}
|
|
884
|
+
if (ueSoftphone.initOptions.loginType === "WEBRTC") {
|
|
885
|
+
try {
|
|
886
|
+
await navigator.mediaDevices.getUserMedia({ audio: true })
|
|
887
|
+
} catch (error) {
|
|
888
|
+
params.fail({
|
|
889
|
+
success: false,
|
|
890
|
+
message: "无麦克风权限!"
|
|
891
|
+
});
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
867
895
|
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
868
896
|
const query: DialoutParams = {
|
|
869
897
|
customerNumber: params.customerNumber,
|
|
@@ -897,6 +925,14 @@ export default class ueSoftphone {
|
|
|
897
925
|
// if (params.groupareaCode) {
|
|
898
926
|
// query.groupareaCode = params.groupareaCode;
|
|
899
927
|
// }
|
|
928
|
+
if (params.numberGroupId) {
|
|
929
|
+
query.numberGroupId = params.numberGroupId
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
if (params.numberGroupName) {
|
|
933
|
+
query.numberGroupName = params.numberGroupName
|
|
934
|
+
}
|
|
935
|
+
|
|
900
936
|
const options = ueSoftphone.initOptions;
|
|
901
937
|
const isStrongHint = true;
|
|
902
938
|
// typeof options.isStrongHint === "boolean" ? options.isStrongHint : true;
|
|
@@ -1180,6 +1216,7 @@ export default class ueSoftphone {
|
|
|
1180
1216
|
});
|
|
1181
1217
|
return;
|
|
1182
1218
|
}
|
|
1219
|
+
|
|
1183
1220
|
if (params.mode === null || params.mode === undefined) {
|
|
1184
1221
|
params.fail({
|
|
1185
1222
|
success: false,
|
|
@@ -1192,13 +1229,9 @@ export default class ueSoftphone {
|
|
|
1192
1229
|
message: "Parameter number is required!"
|
|
1193
1230
|
});
|
|
1194
1231
|
return;
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
message: "Parameter agentNumber is required!"
|
|
1199
|
-
});
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
params.agentNumber = ueSoftphone.agentInfo.agentNumber
|
|
1202
1235
|
|
|
1203
1236
|
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1204
1237
|
ueSoftphone.request(server + "/call/api/call/consult", {
|
|
@@ -1662,7 +1695,7 @@ export default class ueSoftphone {
|
|
|
1662
1695
|
...audioObj
|
|
1663
1696
|
});
|
|
1664
1697
|
ueSoftphone.agentInfo.loginType = params.loginType;
|
|
1665
|
-
|
|
1698
|
+
ueSoftphone.initOptions.loginType= params.loginType;
|
|
1666
1699
|
if (params.loginType === "WEBRTC") {
|
|
1667
1700
|
that._webPhoneApi().connect();
|
|
1668
1701
|
} else if (params.loginType === "PSTN") {
|
|
@@ -2061,3 +2094,30 @@ class ueWebsocket {
|
|
|
2061
2094
|
this.ws.disconnect();
|
|
2062
2095
|
}
|
|
2063
2096
|
}
|
|
2097
|
+
|
|
2098
|
+
class AudioTask {
|
|
2099
|
+
ringAudioRunning: boolean
|
|
2100
|
+
private ringAudio: HTMLAudioElement
|
|
2101
|
+
|
|
2102
|
+
constructor(ringingUrl) {
|
|
2103
|
+
this.ringAudio = new Audio(ringingUrl)
|
|
2104
|
+
this.ringAudio.loop = true
|
|
2105
|
+
this.ringAudioRunning = false
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
async ringAudioPlay(): Promise<void> {
|
|
2109
|
+
if (this.ringAudioRunning) {
|
|
2110
|
+
return
|
|
2111
|
+
} else {
|
|
2112
|
+
await this.ringAudio.play()
|
|
2113
|
+
this.ringAudioRunning = true
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
async ringAudioPause(): Promise<void> {
|
|
2118
|
+
if (!this.ringAudio.paused) {
|
|
2119
|
+
await this.ringAudio.pause()
|
|
2120
|
+
this.ringAudioRunning = false
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
}
|