ue-softphone-sdk-beta 3.0.20 → 3.0.21
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/package.json +1 -1
- package/src/index.ts +303 -303
package/src/index.ts
CHANGED
|
@@ -245,7 +245,7 @@ const networkMonitoringConfig: networkMonitoringParams = {
|
|
|
245
245
|
delay: 0
|
|
246
246
|
};
|
|
247
247
|
|
|
248
|
-
export default class
|
|
248
|
+
export default class ueSoftphone {
|
|
249
249
|
static ueTimer: any; // 监控里面的定时器
|
|
250
250
|
static loginToken: String | undefined;
|
|
251
251
|
static agentInfo: any;
|
|
@@ -273,8 +273,8 @@ export default class ueSoftphoneBeta {
|
|
|
273
273
|
private attachNlsTranslationEventCallbacks: any;
|
|
274
274
|
|
|
275
275
|
constructor(options: InitOptions = {}) {
|
|
276
|
-
options.error = typeof options.error == "function" ? options.error :
|
|
277
|
-
options.success = typeof options.success == "function" ? options.success :
|
|
276
|
+
options.error = typeof options.error == "function" ? options.error : ueSoftphone.noop;
|
|
277
|
+
options.success = typeof options.success == "function" ? options.success : ueSoftphone.noop;
|
|
278
278
|
// if (options.accountId === null || options.accountId === undefined) {
|
|
279
279
|
// options.error({message: "Invalid accountId"});
|
|
280
280
|
// return
|
|
@@ -303,36 +303,36 @@ export default class ueSoftphoneBeta {
|
|
|
303
303
|
this.init(options);
|
|
304
304
|
}
|
|
305
305
|
private init(options: InitOptions = {}) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
306
|
+
ueSoftphone.trace = ueSoftphone.noop;
|
|
307
|
+
ueSoftphone.debug = ueSoftphone.noop;
|
|
308
|
+
ueSoftphone.log = ueSoftphone.noop;
|
|
309
|
+
ueSoftphone.warn = ueSoftphone.noop;
|
|
310
|
+
ueSoftphone.error = ueSoftphone.noop;
|
|
311
311
|
if (options.debug === true || options.debug === "all") {
|
|
312
312
|
// Enable all debugging levels
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
313
|
+
ueSoftphone.trace = console.trace.bind(console);
|
|
314
|
+
ueSoftphone.debug = console.debug.bind(console);
|
|
315
|
+
ueSoftphone.log = console.log.bind(console);
|
|
316
|
+
ueSoftphone.warn = console.warn.bind(console);
|
|
317
|
+
ueSoftphone.error = console.error.bind(console);
|
|
318
318
|
} else if (Array.isArray(options.debug)) {
|
|
319
319
|
for (var i in options.debug) {
|
|
320
320
|
var d = options.debug[i];
|
|
321
321
|
switch (d) {
|
|
322
322
|
case "trace":
|
|
323
|
-
|
|
323
|
+
ueSoftphone.trace = console.trace.bind(console);
|
|
324
324
|
break;
|
|
325
325
|
case "debug":
|
|
326
|
-
|
|
326
|
+
ueSoftphone.debug = console.debug.bind(console);
|
|
327
327
|
break;
|
|
328
328
|
case "log":
|
|
329
|
-
|
|
329
|
+
ueSoftphone.log = console.log.bind(console);
|
|
330
330
|
break;
|
|
331
331
|
case "warn":
|
|
332
|
-
|
|
332
|
+
ueSoftphone.warn = console.warn.bind(console);
|
|
333
333
|
break;
|
|
334
334
|
case "error":
|
|
335
|
-
|
|
335
|
+
ueSoftphone.error = console.error.bind(console);
|
|
336
336
|
break;
|
|
337
337
|
default:
|
|
338
338
|
console.error(
|
|
@@ -344,23 +344,23 @@ export default class ueSoftphoneBeta {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
ueSoftphone.log("Initializing library");
|
|
348
348
|
|
|
349
349
|
const usedDependencies =
|
|
350
350
|
// options.dependencies ||
|
|
351
|
-
|
|
351
|
+
ueSoftphone.useDefaultDependencies({
|
|
352
352
|
WebSocket: ueWebsocket
|
|
353
353
|
});
|
|
354
354
|
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
ueSoftphone.newWebSocket = usedDependencies.newWebSocket;
|
|
356
|
+
ueSoftphone.request = usedDependencies.request;
|
|
357
357
|
this.login(options);
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
private async login(options: InitOptions) {
|
|
361
361
|
console.log(options,"options");
|
|
362
|
-
|
|
363
|
-
const server = options.server ||
|
|
362
|
+
ueSoftphone.UserConfig = options
|
|
363
|
+
const server = options.server || ueSoftphone.callApiUrl;
|
|
364
364
|
const loginName = options.agentNumber + "@" + options.accountId;
|
|
365
365
|
const loginType = options.loginType;
|
|
366
366
|
// const signAuth = options.signAuth;
|
|
@@ -391,7 +391,7 @@ export default class ueSoftphoneBeta {
|
|
|
391
391
|
actionData.password = options.password as string; //md5(options.password as string)
|
|
392
392
|
}
|
|
393
393
|
// 登录前会获取pk密钥,进行加密之后,=》 login(loginToken等) =》loginInfo(user,account等)
|
|
394
|
-
|
|
394
|
+
ueSoftphone.request(server + "/platform/public/loginPre", {
|
|
395
395
|
verb: "GET",
|
|
396
396
|
success: (preInfo: any) => {
|
|
397
397
|
if (preInfo && preInfo.success && preInfo.data) {
|
|
@@ -402,21 +402,21 @@ export default class ueSoftphoneBeta {
|
|
|
402
402
|
const md5Password = md5(actionData.password);
|
|
403
403
|
const rsaPassword: any = encryptor.encrypt(md5Password);
|
|
404
404
|
actionData.password = rsaPassword;
|
|
405
|
-
|
|
405
|
+
ueSoftphone.request(server + "/platform/public/login", {
|
|
406
406
|
verb: "POST",
|
|
407
407
|
body: actionData,
|
|
408
408
|
success: (res: any) => {
|
|
409
409
|
if (res.success) {
|
|
410
|
-
|
|
410
|
+
ueSoftphone.request(server + "/platform/action/loginInfo", {
|
|
411
411
|
verb: "GET",
|
|
412
412
|
loginToken: res.data.loginToken,
|
|
413
413
|
sessionId: res.data.sessionId,
|
|
414
414
|
success: (loginInfo: any) => {
|
|
415
415
|
if (loginInfo.success) {
|
|
416
416
|
if (loginInfo.data.agent) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
417
|
+
ueSoftphone.agentInfo = loginInfo.data.agent;
|
|
418
|
+
ueSoftphone.loginToken = loginInfo.data.loginToken;
|
|
419
|
+
ueSoftphone.initOptions = {
|
|
420
420
|
...options,
|
|
421
421
|
audioInfo: audioObj
|
|
422
422
|
};
|
|
@@ -502,11 +502,11 @@ export default class ueSoftphoneBeta {
|
|
|
502
502
|
}
|
|
503
503
|
static createEventHandle(callbacks: any = {}) {
|
|
504
504
|
callbacks.success =
|
|
505
|
-
typeof callbacks.success == "function" ? callbacks.success :
|
|
506
|
-
callbacks.error = typeof callbacks.error == "function" ? callbacks.error :
|
|
505
|
+
typeof callbacks.success == "function" ? callbacks.success : ueSoftphone.noop;
|
|
506
|
+
callbacks.error = typeof callbacks.error == "function" ? callbacks.error : ueSoftphone.noop;
|
|
507
507
|
callbacks.message =
|
|
508
|
-
typeof callbacks.message == "function" ? callbacks.message :
|
|
509
|
-
callbacks.event = typeof callbacks.event == "function" ? callbacks.event :
|
|
508
|
+
typeof callbacks.message == "function" ? callbacks.message : ueSoftphone.noop;
|
|
509
|
+
callbacks.event = typeof callbacks.event == "function" ? callbacks.event : ueSoftphone.noop;
|
|
510
510
|
callbacks.server =
|
|
511
511
|
callbacks.serve === null || callbacks.serve === undefined
|
|
512
512
|
? "ws://152.136.72.209:3201/phoneBarGateway"
|
|
@@ -514,22 +514,22 @@ export default class ueSoftphoneBeta {
|
|
|
514
514
|
|
|
515
515
|
if (callbacks.SocketOptions === null || callbacks.SocketOptions === undefined) {
|
|
516
516
|
callbacks.SocketOptions = {};
|
|
517
|
-
|
|
517
|
+
ueSoftphone.error({ message: "login response error!" });
|
|
518
518
|
}
|
|
519
|
-
this.Socketinstance =
|
|
519
|
+
this.Socketinstance = ueSoftphone.newWebSocket(callbacks.server, callbacks.SocketOptions);
|
|
520
520
|
this.Socketinstance.on("connect", () => {
|
|
521
521
|
callbacks.success("connect event serve success!");
|
|
522
522
|
callbacks.suc();
|
|
523
|
-
// (
|
|
524
|
-
// agentNumber:
|
|
525
|
-
// agentName:
|
|
526
|
-
// mobile:
|
|
527
|
-
// sipNumber:
|
|
528
|
-
// loginStatus:
|
|
529
|
-
// loginType:
|
|
530
|
-
// restTime:
|
|
531
|
-
// toAnswerOffline:
|
|
532
|
-
// ...(
|
|
523
|
+
// (ueSoftphone.initOptions.success as Function)({
|
|
524
|
+
// agentNumber: ueSoftphone.agentInfo.agentNumber,
|
|
525
|
+
// agentName: ueSoftphone.agentInfo.agentName,
|
|
526
|
+
// mobile: ueSoftphone.agentInfo.mobile,
|
|
527
|
+
// sipNumber: ueSoftphone.agentInfo.sipNumber,
|
|
528
|
+
// loginStatus: ueSoftphone.agentInfo.loginStatus,
|
|
529
|
+
// loginType: ueSoftphone.agentInfo.loginType,
|
|
530
|
+
// restTime: ueSoftphone.agentInfo.restTime,
|
|
531
|
+
// toAnswerOffline: ueSoftphone.agentInfo.toAnswerOffline || '0',
|
|
532
|
+
// ...(ueSoftphone.initOptions.audioInfo || {})
|
|
533
533
|
// })
|
|
534
534
|
});
|
|
535
535
|
|
|
@@ -549,15 +549,15 @@ export default class ueSoftphoneBeta {
|
|
|
549
549
|
data: event.data
|
|
550
550
|
});
|
|
551
551
|
|
|
552
|
-
if (
|
|
552
|
+
if (ueSoftphone.initOptions.loginType === "WEBRTC") {
|
|
553
553
|
if (event.data && event.data.callType && event.data.callType === 'callin' && event.data.eventType && event.data.eventType ==='ring') {
|
|
554
|
-
if (!
|
|
555
|
-
|
|
554
|
+
if (!ueSoftphone.AudioTask) {
|
|
555
|
+
ueSoftphone.AudioTask = new AudioTask('https://softphone.useasy.cn/ring.wav');
|
|
556
556
|
}
|
|
557
|
-
|
|
557
|
+
ueSoftphone.AudioTask.ringAudioPlay()
|
|
558
558
|
} else {
|
|
559
|
-
if (
|
|
560
|
-
|
|
559
|
+
if (ueSoftphone.AudioTask) {
|
|
560
|
+
ueSoftphone.AudioTask.ringAudioPause()
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
}
|
|
@@ -571,9 +571,9 @@ export default class ueSoftphoneBeta {
|
|
|
571
571
|
if (event.subType === "KICK_OFF") {
|
|
572
572
|
if (event.data.kickoff === true) {
|
|
573
573
|
this.Socketinstance.disconnect();
|
|
574
|
-
|
|
574
|
+
ueSoftphone.loginToken = 'KICK_OFF'
|
|
575
575
|
try {
|
|
576
|
-
|
|
576
|
+
ueSoftphone.webPhone.disconnect();
|
|
577
577
|
console.log(event,"互踢")
|
|
578
578
|
} catch (error) {}
|
|
579
579
|
callbacks.event({
|
|
@@ -587,14 +587,14 @@ export default class ueSoftphoneBeta {
|
|
|
587
587
|
|
|
588
588
|
// 若是webrtc的方式,会获取webrtc相关信息,注册地址,注册密码等。
|
|
589
589
|
private getWebrtcInfo = (server: any, options: any) => {
|
|
590
|
-
|
|
590
|
+
ueSoftphone.request(server + "/call/api/sip/webrtc/config/query", {
|
|
591
591
|
verb: "GET",
|
|
592
|
-
loginToken:
|
|
593
|
-
sessionId:
|
|
592
|
+
loginToken: ueSoftphone.loginToken,
|
|
593
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
594
594
|
success: (webrtcInfo: any) => {
|
|
595
595
|
if (webrtcInfo.success && webrtcInfo.data) {
|
|
596
|
-
|
|
597
|
-
|
|
596
|
+
ueSoftphone.agentextras = webrtcInfo.data;
|
|
597
|
+
ueSoftphone.initWebrtcEvent(webrtcInfo.data);
|
|
598
598
|
} else {
|
|
599
599
|
(options.error as Function)({
|
|
600
600
|
...webrtcInfo
|
|
@@ -615,7 +615,7 @@ export default class ueSoftphoneBeta {
|
|
|
615
615
|
// if (this.attachMonitorEventCallbacks) {
|
|
616
616
|
// this.attachMonitorEventCallbacks.serve = options.sdkMonitorUrl;
|
|
617
617
|
// // this.attachMonitorEventCallbacks.sdkMonitorType =
|
|
618
|
-
// //
|
|
618
|
+
// // ueSoftphone.initOptions.sdkMonitorType || [];
|
|
619
619
|
// this.attachMonitorEventCallbacks.SocketOptions = {
|
|
620
620
|
// query: {
|
|
621
621
|
// 电话条事件回调
|
|
@@ -628,10 +628,10 @@ export default class ueSoftphoneBeta {
|
|
|
628
628
|
) => {
|
|
629
629
|
if (this.attachEventCallbacks) {
|
|
630
630
|
// 每次创建链接的时候,要获取最新的ws token
|
|
631
|
-
|
|
631
|
+
ueSoftphone.request(server + "/platform/action/refreshWsToken", {
|
|
632
632
|
verb: "GET",
|
|
633
|
-
loginToken:
|
|
634
|
-
sessionId:
|
|
633
|
+
loginToken: ueSoftphone.loginToken,
|
|
634
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
635
635
|
success: (res: any) => {
|
|
636
636
|
if (res && res.data) {
|
|
637
637
|
let serverUrl = "";
|
|
@@ -654,8 +654,8 @@ export default class ueSoftphoneBeta {
|
|
|
654
654
|
}),
|
|
655
655
|
timestamp: res.data.timestamp,
|
|
656
656
|
clientType: 1,
|
|
657
|
-
pushHangupStatistics:
|
|
658
|
-
pushCallinRingStatistics:
|
|
657
|
+
pushHangupStatistics: ueSoftphone.initOptions.pushHangupStatistics || false,
|
|
658
|
+
pushCallinRingStatistics: ueSoftphone.initOptions.pushCallinRingStatistics || false
|
|
659
659
|
},
|
|
660
660
|
reconnectionDelay: 3000,
|
|
661
661
|
"force new connection": true,
|
|
@@ -663,7 +663,7 @@ export default class ueSoftphoneBeta {
|
|
|
663
663
|
timeout: 5000
|
|
664
664
|
};
|
|
665
665
|
this.attachEventCallbacks.suc = suc;
|
|
666
|
-
|
|
666
|
+
ueSoftphone.createEventHandle(this.attachEventCallbacks);
|
|
667
667
|
}
|
|
668
668
|
},
|
|
669
669
|
error: (error: any) => {
|
|
@@ -677,9 +677,9 @@ export default class ueSoftphoneBeta {
|
|
|
677
677
|
|
|
678
678
|
// 网络监测监听
|
|
679
679
|
private attachNetworkCallbacks: any = {
|
|
680
|
-
message:
|
|
681
|
-
error:
|
|
682
|
-
success:
|
|
680
|
+
message: ueSoftphone.noop,
|
|
681
|
+
error: ueSoftphone.noop,
|
|
682
|
+
success: ueSoftphone.noop
|
|
683
683
|
};
|
|
684
684
|
private initnNetworkMonitoring = (pushServer, callbacks:any) => {
|
|
685
685
|
let currentUrl = ''
|
|
@@ -702,7 +702,7 @@ export default class ueSoftphoneBeta {
|
|
|
702
702
|
// }
|
|
703
703
|
const startTime = new Date().getTime()
|
|
704
704
|
networkMonitoringConfig.requestState = true
|
|
705
|
-
|
|
705
|
+
ueSoftphone.request(currentUrl + "/ready", {
|
|
706
706
|
method: "GET",
|
|
707
707
|
success: (res: any) => {
|
|
708
708
|
if (res.success) {
|
|
@@ -728,9 +728,9 @@ export default class ueSoftphoneBeta {
|
|
|
728
728
|
|
|
729
729
|
public listenCallNetork = (callbacks: OnCallEventParams) => {
|
|
730
730
|
if (callbacks) {
|
|
731
|
-
this.attachNetworkCallbacks.message = callbacks.message && typeof callbacks.message == "function" ? callbacks.message :
|
|
732
|
-
this.attachNetworkCallbacks.success = callbacks.success && typeof callbacks.success == "function" ? callbacks.success :
|
|
733
|
-
this.attachNetworkCallbacks.error = callbacks.error && typeof callbacks.error == "function" ? callbacks.error :
|
|
731
|
+
this.attachNetworkCallbacks.message = callbacks.message && typeof callbacks.message == "function" ? callbacks.message : ueSoftphone.noop;
|
|
732
|
+
this.attachNetworkCallbacks.success = callbacks.success && typeof callbacks.success == "function" ? callbacks.success : ueSoftphone.noop;
|
|
733
|
+
this.attachNetworkCallbacks.error = callbacks.error && typeof callbacks.error == "function" ? callbacks.error : ueSoftphone.noop;
|
|
734
734
|
}
|
|
735
735
|
};
|
|
736
736
|
|
|
@@ -744,10 +744,10 @@ export default class ueSoftphoneBeta {
|
|
|
744
744
|
) => {
|
|
745
745
|
if (this.attachMonitorEventCallbacks||this.attachNlsTranslationEventCallbacks) {
|
|
746
746
|
// 每次创建链接的时候,要获取最新的ws token
|
|
747
|
-
|
|
747
|
+
ueSoftphone.request(server + "/platform/action/refreshWsToken", {
|
|
748
748
|
verb: "GET",
|
|
749
|
-
loginToken:
|
|
750
|
-
sessionId:
|
|
749
|
+
loginToken: ueSoftphone.loginToken,
|
|
750
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
751
751
|
success: (res: any) => {
|
|
752
752
|
if (res && res.data) {
|
|
753
753
|
let serverUrl = "";
|
|
@@ -756,7 +756,7 @@ export default class ueSoftphoneBeta {
|
|
|
756
756
|
serverUrl = item.url;
|
|
757
757
|
}
|
|
758
758
|
});
|
|
759
|
-
if(this.attachMonitorEventCallbacks&&
|
|
759
|
+
if(this.attachMonitorEventCallbacks&&ueSoftphone.UserConfig.isOpenCallQueue){
|
|
760
760
|
this.attachMonitorEventCallbacks.serve = serverUrl;
|
|
761
761
|
this.attachMonitorEventCallbacks.SocketOptions = {
|
|
762
762
|
query: {
|
|
@@ -778,9 +778,9 @@ export default class ueSoftphoneBeta {
|
|
|
778
778
|
timeout: 5000
|
|
779
779
|
};
|
|
780
780
|
this.attachMonitorEventCallbacks.suc = suc;
|
|
781
|
-
|
|
781
|
+
ueSoftphone.createQueueMonitorEventHandle(this.attachMonitorEventCallbacks);
|
|
782
782
|
}
|
|
783
|
-
if(this.attachNlsTranslationEventCallbacks&&
|
|
783
|
+
if(this.attachNlsTranslationEventCallbacks&&ueSoftphone.UserConfig.openNlsTranslation){
|
|
784
784
|
this.attachNlsTranslationEventCallbacks.serve = serverUrl;
|
|
785
785
|
this.attachNlsTranslationEventCallbacks.SocketOptions = {
|
|
786
786
|
query: {
|
|
@@ -802,7 +802,7 @@ export default class ueSoftphoneBeta {
|
|
|
802
802
|
timeout: 5000
|
|
803
803
|
};
|
|
804
804
|
this.attachNlsTranslationEventCallbacks.suc = suc;
|
|
805
|
-
|
|
805
|
+
ueSoftphone.createQueueMonitorEventHandle(this.attachNlsTranslationEventCallbacks);
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
},
|
|
@@ -819,11 +819,11 @@ export default class ueSoftphoneBeta {
|
|
|
819
819
|
private initQueue = (
|
|
820
820
|
server: any
|
|
821
821
|
) => {
|
|
822
|
-
|
|
822
|
+
ueSoftphone.request(server + "/call/monitor/agent/queue/query", {
|
|
823
823
|
verb: "POST",
|
|
824
824
|
body: {
|
|
825
|
-
accountId:
|
|
826
|
-
agentId:
|
|
825
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
826
|
+
agentId: ueSoftphone.agentInfo._id
|
|
827
827
|
},
|
|
828
828
|
success: (res: any) => {
|
|
829
829
|
if (res && res.data) {
|
|
@@ -840,10 +840,10 @@ export default class ueSoftphoneBeta {
|
|
|
840
840
|
// 更新呼叫队列socket消息推送
|
|
841
841
|
static createQueueMonitorEventHandle(callbacks: any = {}) {
|
|
842
842
|
callbacks.success =
|
|
843
|
-
typeof callbacks.success == "function" ? callbacks.success :
|
|
844
|
-
callbacks.error = typeof callbacks.error == "function" ? callbacks.error :
|
|
843
|
+
typeof callbacks.success == "function" ? callbacks.success : ueSoftphone.noop;
|
|
844
|
+
callbacks.error = typeof callbacks.error == "function" ? callbacks.error : ueSoftphone.noop;
|
|
845
845
|
callbacks.message =
|
|
846
|
-
typeof callbacks.message == "function" ? callbacks.message :
|
|
846
|
+
typeof callbacks.message == "function" ? callbacks.message : ueSoftphone.noop;
|
|
847
847
|
callbacks.server =
|
|
848
848
|
callbacks.serve === null || callbacks.serve === undefined
|
|
849
849
|
? "ue-dev1.useasy.cn"
|
|
@@ -851,10 +851,10 @@ export default class ueSoftphoneBeta {
|
|
|
851
851
|
|
|
852
852
|
if (callbacks.SocketOptions === null || callbacks.SocketOptions === undefined) {
|
|
853
853
|
callbacks.SocketOptions = {};
|
|
854
|
-
|
|
854
|
+
ueSoftphone.error({ message: "login response error!" });
|
|
855
855
|
}
|
|
856
856
|
|
|
857
|
-
this.MonitorSocketinstance =
|
|
857
|
+
this.MonitorSocketinstance = ueSoftphone.newWebSocket(
|
|
858
858
|
callbacks.server,
|
|
859
859
|
callbacks.SocketOptions
|
|
860
860
|
);
|
|
@@ -862,7 +862,7 @@ export default class ueSoftphoneBeta {
|
|
|
862
862
|
this.MonitorSocketinstance.on("connect", () => {
|
|
863
863
|
callbacks.success("connect event serve success!");
|
|
864
864
|
callbacks.suc();
|
|
865
|
-
|
|
865
|
+
ueSoftphone.log("监控connect========");
|
|
866
866
|
});
|
|
867
867
|
this.MonitorSocketinstance.on("error", (error: string, fn: Function) => {
|
|
868
868
|
callbacks.error({
|
|
@@ -888,7 +888,7 @@ export default class ueSoftphoneBeta {
|
|
|
888
888
|
if (event.data.kickoff === true) {
|
|
889
889
|
this.MonitorSocketinstance.disconnect();
|
|
890
890
|
try {
|
|
891
|
-
|
|
891
|
+
ueSoftphone.webPhone.disconnect();
|
|
892
892
|
console.log(event,"呼叫队列互踢")
|
|
893
893
|
} catch (error) {}
|
|
894
894
|
callbacks.message({
|
|
@@ -908,8 +908,8 @@ export default class ueSoftphoneBeta {
|
|
|
908
908
|
// if (callbacks.sdkMonitorType) {
|
|
909
909
|
// const sdkMonitorTypeArr = callbacks.sdkMonitorType || [];
|
|
910
910
|
// if (Array.isArray(sdkMonitorTypeArr)) {
|
|
911
|
-
// clearInterval(
|
|
912
|
-
//
|
|
911
|
+
// clearInterval(ueSoftphone.ueTimer);
|
|
912
|
+
// ueSoftphone.ueTimer = window.setInterval(() => {
|
|
913
913
|
// // category: summary: 概览数据, agent: 座席监控, queue: 技能组监控, trunkNumber: 服务号监控
|
|
914
914
|
// sdkMonitorTypeArr.forEach((item) => {
|
|
915
915
|
// this.MonitorSocketinstance.emit("monitor", "bizMonitor", { category: item });
|
|
@@ -988,7 +988,7 @@ export default class ueSoftphoneBeta {
|
|
|
988
988
|
fetching
|
|
989
989
|
.then(function (response: any) {
|
|
990
990
|
if (response.ok) {
|
|
991
|
-
if (typeof options.success === typeof
|
|
991
|
+
if (typeof options.success === typeof ueSoftphone.noop) {
|
|
992
992
|
return response
|
|
993
993
|
.json()
|
|
994
994
|
.then(function (parsed: any) {
|
|
@@ -1013,7 +1013,7 @@ export default class ueSoftphoneBeta {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
})
|
|
1015
1015
|
.catch(function (error: any) {
|
|
1016
|
-
if (typeof options.error === typeof
|
|
1016
|
+
if (typeof options.error === typeof ueSoftphone.noop) {
|
|
1017
1017
|
options.error(error.message || "<< internal error >>", error);
|
|
1018
1018
|
}
|
|
1019
1019
|
});
|
|
@@ -1024,7 +1024,7 @@ export default class ueSoftphoneBeta {
|
|
|
1024
1024
|
|
|
1025
1025
|
// webrtc事件回调
|
|
1026
1026
|
private static initWebrtcEvent = async (extras: any) => {
|
|
1027
|
-
|
|
1027
|
+
ueSoftphone.webPhone = new UeWebrtc({
|
|
1028
1028
|
server: extras.wssUrl,
|
|
1029
1029
|
sip: extras.sip,
|
|
1030
1030
|
secret: extras.password
|
|
@@ -1110,16 +1110,16 @@ export default class ueSoftphoneBeta {
|
|
|
1110
1110
|
// 外呼
|
|
1111
1111
|
async callout(params: DialoutParams) {
|
|
1112
1112
|
params.success =
|
|
1113
|
-
params && typeof params.success == "function" ? params.success :
|
|
1114
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1115
|
-
if (
|
|
1113
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1114
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1115
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1116
1116
|
params.fail({
|
|
1117
1117
|
success: false,
|
|
1118
1118
|
message: "initialization not complete!"
|
|
1119
1119
|
});
|
|
1120
1120
|
return;
|
|
1121
1121
|
}
|
|
1122
|
-
if (
|
|
1122
|
+
if (ueSoftphone.loginToken === 'KICK_OFF') {
|
|
1123
1123
|
params.fail({
|
|
1124
1124
|
success: false,
|
|
1125
1125
|
message: "您的座席账号正在别处登录,当前页面电话条已退出。"
|
|
@@ -1132,7 +1132,7 @@ export default class ueSoftphoneBeta {
|
|
|
1132
1132
|
// if (params.encryptionFields) {
|
|
1133
1133
|
// encryptionFields = params.encryptionFields;
|
|
1134
1134
|
// }
|
|
1135
|
-
if (
|
|
1135
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1136
1136
|
params.fail({
|
|
1137
1137
|
success: false,
|
|
1138
1138
|
message: "initialization not complete!"
|
|
@@ -1147,7 +1147,7 @@ export default class ueSoftphoneBeta {
|
|
|
1147
1147
|
});
|
|
1148
1148
|
return;
|
|
1149
1149
|
}
|
|
1150
|
-
if (
|
|
1150
|
+
if (ueSoftphone.initOptions.loginType === "WEBRTC") {
|
|
1151
1151
|
try {
|
|
1152
1152
|
await navigator.mediaDevices.getUserMedia({ audio: true })
|
|
1153
1153
|
} catch (error) {
|
|
@@ -1158,14 +1158,14 @@ export default class ueSoftphoneBeta {
|
|
|
1158
1158
|
return;
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
|
-
const server =
|
|
1161
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1162
1162
|
const query: DialoutParams = {
|
|
1163
1163
|
customerNumber: params.customerNumber,
|
|
1164
|
-
agentNumber:
|
|
1165
|
-
accountId:
|
|
1166
|
-
agentId:
|
|
1164
|
+
agentNumber: ueSoftphone.agentInfo.agentNumber,
|
|
1165
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1166
|
+
agentId: ueSoftphone.agentInfo._id,
|
|
1167
1167
|
loginType:
|
|
1168
|
-
params.loginType ||
|
|
1168
|
+
params.loginType || ueSoftphone.agentInfo.loginType || ueSoftphone.initOptions.loginType
|
|
1169
1169
|
};
|
|
1170
1170
|
if (params.agentTimeout) {
|
|
1171
1171
|
query.agentTimeout = params.agentTimeout;
|
|
@@ -1199,7 +1199,7 @@ export default class ueSoftphoneBeta {
|
|
|
1199
1199
|
query.numberGroupName = params.numberGroupName
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
|
-
const options =
|
|
1202
|
+
const options = ueSoftphone.initOptions;
|
|
1203
1203
|
const isStrongHint = true;
|
|
1204
1204
|
// typeof options.isStrongHint === "boolean" ? options.isStrongHint : true;
|
|
1205
1205
|
let audioObj;
|
|
@@ -1210,11 +1210,11 @@ export default class ueSoftphoneBeta {
|
|
|
1210
1210
|
console.log(error);
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
|
|
1213
|
+
ueSoftphone.request(server + "/call/api/call/call/out", {
|
|
1214
1214
|
verb: "POST",
|
|
1215
1215
|
body: query,
|
|
1216
|
-
loginToken:
|
|
1217
|
-
sessionId:
|
|
1216
|
+
loginToken: ueSoftphone.loginToken,
|
|
1217
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1218
1218
|
encryptionAlgorithm,
|
|
1219
1219
|
encryptionFields,
|
|
1220
1220
|
success: (res: any) => {
|
|
@@ -1239,10 +1239,10 @@ export default class ueSoftphoneBeta {
|
|
|
1239
1239
|
// 挂机
|
|
1240
1240
|
hangup(params: HangupParams) {
|
|
1241
1241
|
params.success =
|
|
1242
|
-
params && typeof params.success == "function" ? params.success :
|
|
1243
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1242
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1243
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1244
1244
|
|
|
1245
|
-
if (
|
|
1245
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1246
1246
|
params.fail({
|
|
1247
1247
|
success: false,
|
|
1248
1248
|
message: "initialization not complete!"
|
|
@@ -1250,7 +1250,7 @@ export default class ueSoftphoneBeta {
|
|
|
1250
1250
|
return;
|
|
1251
1251
|
}
|
|
1252
1252
|
|
|
1253
|
-
if (
|
|
1253
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1254
1254
|
params.fail({
|
|
1255
1255
|
success: false,
|
|
1256
1256
|
message: "initialization not complete!"
|
|
@@ -1258,14 +1258,14 @@ export default class ueSoftphoneBeta {
|
|
|
1258
1258
|
return;
|
|
1259
1259
|
}
|
|
1260
1260
|
|
|
1261
|
-
const server =
|
|
1261
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1262
1262
|
|
|
1263
|
-
|
|
1263
|
+
ueSoftphone.request(server + "/call/api/call/hangup", {
|
|
1264
1264
|
verb: "POST",
|
|
1265
1265
|
body: {},
|
|
1266
|
-
loginToken:
|
|
1267
|
-
sessionId:
|
|
1268
|
-
accountId:
|
|
1266
|
+
loginToken: ueSoftphone.loginToken,
|
|
1267
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1268
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1269
1269
|
encryptionAlgorithm,
|
|
1270
1270
|
encryptionFields,
|
|
1271
1271
|
success: (res: any) => {
|
|
@@ -1291,9 +1291,9 @@ export default class ueSoftphoneBeta {
|
|
|
1291
1291
|
holdOrUnHold(params: HoldOrUnHoldParams) {
|
|
1292
1292
|
//保持 取消保持
|
|
1293
1293
|
params.success =
|
|
1294
|
-
params && typeof params.success == "function" ? params.success :
|
|
1295
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1296
|
-
if (
|
|
1294
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1295
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1296
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1297
1297
|
params.fail({
|
|
1298
1298
|
success: false,
|
|
1299
1299
|
message: "initialization not complete!"
|
|
@@ -1301,7 +1301,7 @@ export default class ueSoftphoneBeta {
|
|
|
1301
1301
|
return;
|
|
1302
1302
|
}
|
|
1303
1303
|
|
|
1304
|
-
if (
|
|
1304
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1305
1305
|
params.fail({
|
|
1306
1306
|
success: false,
|
|
1307
1307
|
message: "initialization not complete!"
|
|
@@ -1316,16 +1316,16 @@ export default class ueSoftphoneBeta {
|
|
|
1316
1316
|
});
|
|
1317
1317
|
return;
|
|
1318
1318
|
}
|
|
1319
|
-
const server =
|
|
1319
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1320
1320
|
const query: HoldOrUnHoldParams = {
|
|
1321
1321
|
type: params.type
|
|
1322
1322
|
};
|
|
1323
|
-
|
|
1323
|
+
ueSoftphone.request(server + "/call/api/call/hold", {
|
|
1324
1324
|
verb: "POST",
|
|
1325
1325
|
body: query,
|
|
1326
|
-
loginToken:
|
|
1327
|
-
sessionId:
|
|
1328
|
-
accountId:
|
|
1326
|
+
loginToken: ueSoftphone.loginToken,
|
|
1327
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1328
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1329
1329
|
encryptionAlgorithm,
|
|
1330
1330
|
encryptionFields,
|
|
1331
1331
|
success: (res: any) => {
|
|
@@ -1348,9 +1348,9 @@ export default class ueSoftphoneBeta {
|
|
|
1348
1348
|
muteOrUnMute(params: MuteOrUnMuteParams) {
|
|
1349
1349
|
//静音 取消静音
|
|
1350
1350
|
params.success =
|
|
1351
|
-
params && typeof params.success == "function" ? params.success :
|
|
1352
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1353
|
-
if (
|
|
1351
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1352
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1353
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1354
1354
|
params.fail({
|
|
1355
1355
|
success: false,
|
|
1356
1356
|
message: "initialization not complete!"
|
|
@@ -1358,7 +1358,7 @@ export default class ueSoftphoneBeta {
|
|
|
1358
1358
|
return;
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
-
if (
|
|
1361
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1362
1362
|
params.fail({
|
|
1363
1363
|
success: false,
|
|
1364
1364
|
message: "initialization not complete!"
|
|
@@ -1373,17 +1373,17 @@ export default class ueSoftphoneBeta {
|
|
|
1373
1373
|
});
|
|
1374
1374
|
return;
|
|
1375
1375
|
}
|
|
1376
|
-
const server =
|
|
1376
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1377
1377
|
const query: MuteOrUnMuteParams = {
|
|
1378
1378
|
type: params.type,
|
|
1379
1379
|
direction: params.direction || "all"
|
|
1380
1380
|
};
|
|
1381
|
-
|
|
1381
|
+
ueSoftphone.request(server + "/call/api/call/mute", {
|
|
1382
1382
|
verb: "POST",
|
|
1383
1383
|
body: query,
|
|
1384
|
-
loginToken:
|
|
1385
|
-
sessionId:
|
|
1386
|
-
accountId:
|
|
1384
|
+
loginToken: ueSoftphone.loginToken,
|
|
1385
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1386
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1387
1387
|
encryptionAlgorithm,
|
|
1388
1388
|
encryptionFields,
|
|
1389
1389
|
success: (res: any) => {
|
|
@@ -1405,10 +1405,10 @@ export default class ueSoftphoneBeta {
|
|
|
1405
1405
|
// 转接
|
|
1406
1406
|
transfer(params: TransferParams) {
|
|
1407
1407
|
params.success =
|
|
1408
|
-
params && typeof params.success == "function" ? params.success :
|
|
1409
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1408
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1409
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1410
1410
|
|
|
1411
|
-
if (
|
|
1411
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1412
1412
|
params.fail({
|
|
1413
1413
|
success: false,
|
|
1414
1414
|
message: "initialization not complete!"
|
|
@@ -1416,7 +1416,7 @@ export default class ueSoftphoneBeta {
|
|
|
1416
1416
|
return;
|
|
1417
1417
|
}
|
|
1418
1418
|
|
|
1419
|
-
if (
|
|
1419
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1420
1420
|
params.fail({
|
|
1421
1421
|
success: false,
|
|
1422
1422
|
message: "initialization not complete!"
|
|
@@ -1437,14 +1437,14 @@ export default class ueSoftphoneBeta {
|
|
|
1437
1437
|
return;
|
|
1438
1438
|
}
|
|
1439
1439
|
|
|
1440
|
-
const server =
|
|
1440
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1441
1441
|
|
|
1442
|
-
|
|
1442
|
+
ueSoftphone.request(server + "/call/api/call/transfer", {
|
|
1443
1443
|
verb: "POST",
|
|
1444
1444
|
body: params,
|
|
1445
|
-
loginToken:
|
|
1446
|
-
sessionId:
|
|
1447
|
-
accountId:
|
|
1445
|
+
loginToken: ueSoftphone.loginToken,
|
|
1446
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1447
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1448
1448
|
encryptionAlgorithm,
|
|
1449
1449
|
encryptionFields,
|
|
1450
1450
|
success: (res: any) => {
|
|
@@ -1467,10 +1467,10 @@ export default class ueSoftphoneBeta {
|
|
|
1467
1467
|
// 咨询
|
|
1468
1468
|
consult(params: consultParams) {
|
|
1469
1469
|
params.success =
|
|
1470
|
-
params && typeof params.success == "function" ? params.success :
|
|
1471
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1470
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1471
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1472
1472
|
|
|
1473
|
-
if (
|
|
1473
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1474
1474
|
params.fail({
|
|
1475
1475
|
success: false,
|
|
1476
1476
|
message: "initialization not complete!"
|
|
@@ -1478,7 +1478,7 @@ export default class ueSoftphoneBeta {
|
|
|
1478
1478
|
return;
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
1481
|
-
if (
|
|
1481
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1482
1482
|
params.fail({
|
|
1483
1483
|
success: false,
|
|
1484
1484
|
message: "initialization not complete!"
|
|
@@ -1500,15 +1500,15 @@ export default class ueSoftphoneBeta {
|
|
|
1500
1500
|
return;
|
|
1501
1501
|
}
|
|
1502
1502
|
|
|
1503
|
-
params.agentNumber =
|
|
1503
|
+
params.agentNumber = ueSoftphone.agentInfo.agentNumber
|
|
1504
1504
|
|
|
1505
|
-
const server =
|
|
1506
|
-
|
|
1505
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1506
|
+
ueSoftphone.request(server + "/call/api/call/consult", {
|
|
1507
1507
|
verb: "POST",
|
|
1508
1508
|
body: params,
|
|
1509
|
-
loginToken:
|
|
1510
|
-
sessionId:
|
|
1511
|
-
accountId:
|
|
1509
|
+
loginToken: ueSoftphone.loginToken,
|
|
1510
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1511
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1512
1512
|
encryptionAlgorithm,
|
|
1513
1513
|
encryptionFields,
|
|
1514
1514
|
success: (res: any) => {
|
|
@@ -1531,10 +1531,10 @@ export default class ueSoftphoneBeta {
|
|
|
1531
1531
|
// 取消咨询
|
|
1532
1532
|
cancelconsult(params: cancleConsultParams) {
|
|
1533
1533
|
params.success =
|
|
1534
|
-
params && typeof params.success == "function" ? params.success :
|
|
1535
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1534
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1535
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1536
1536
|
|
|
1537
|
-
if (
|
|
1537
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1538
1538
|
params.fail({
|
|
1539
1539
|
success: false,
|
|
1540
1540
|
message: "initialization not complete!"
|
|
@@ -1542,7 +1542,7 @@ export default class ueSoftphoneBeta {
|
|
|
1542
1542
|
return;
|
|
1543
1543
|
}
|
|
1544
1544
|
|
|
1545
|
-
if (
|
|
1545
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1546
1546
|
params.fail({
|
|
1547
1547
|
success: false,
|
|
1548
1548
|
message: "initialization not complete!"
|
|
@@ -1550,14 +1550,14 @@ export default class ueSoftphoneBeta {
|
|
|
1550
1550
|
return;
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
|
-
const server =
|
|
1553
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1554
1554
|
|
|
1555
|
-
|
|
1555
|
+
ueSoftphone.request(server + "/call/api/call/consult/cancel", {
|
|
1556
1556
|
verb: "POST",
|
|
1557
1557
|
body: params,
|
|
1558
|
-
loginToken:
|
|
1559
|
-
sessionId:
|
|
1560
|
-
accountId:
|
|
1558
|
+
loginToken: ueSoftphone.loginToken,
|
|
1559
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1560
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1561
1561
|
encryptionAlgorithm,
|
|
1562
1562
|
encryptionFields,
|
|
1563
1563
|
success: (res: any) => {
|
|
@@ -1580,10 +1580,10 @@ export default class ueSoftphoneBeta {
|
|
|
1580
1580
|
// 结束咨询
|
|
1581
1581
|
endConsult(params: stopConsultParams) {
|
|
1582
1582
|
params.success =
|
|
1583
|
-
params && typeof params.success == "function" ? params.success :
|
|
1584
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1583
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1584
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1585
1585
|
|
|
1586
|
-
if (
|
|
1586
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1587
1587
|
params.fail({
|
|
1588
1588
|
success: false,
|
|
1589
1589
|
message: "initialization not complete!"
|
|
@@ -1591,7 +1591,7 @@ export default class ueSoftphoneBeta {
|
|
|
1591
1591
|
return;
|
|
1592
1592
|
}
|
|
1593
1593
|
|
|
1594
|
-
if (
|
|
1594
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1595
1595
|
params.fail({
|
|
1596
1596
|
success: false,
|
|
1597
1597
|
message: "initialization not complete!"
|
|
@@ -1599,14 +1599,14 @@ export default class ueSoftphoneBeta {
|
|
|
1599
1599
|
return;
|
|
1600
1600
|
}
|
|
1601
1601
|
|
|
1602
|
-
const server =
|
|
1602
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1603
1603
|
|
|
1604
|
-
|
|
1604
|
+
ueSoftphone.request(server + "/call/api/call/consult/stop", {
|
|
1605
1605
|
verb: "POST",
|
|
1606
1606
|
body: params,
|
|
1607
|
-
loginToken:
|
|
1608
|
-
sessionId:
|
|
1609
|
-
accountId:
|
|
1607
|
+
loginToken: ueSoftphone.loginToken,
|
|
1608
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1609
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1610
1610
|
encryptionAlgorithm,
|
|
1611
1611
|
encryptionFields,
|
|
1612
1612
|
success: (res: any) => {
|
|
@@ -1629,10 +1629,10 @@ export default class ueSoftphoneBeta {
|
|
|
1629
1629
|
// 咨询接回
|
|
1630
1630
|
callbackConsult(params: resumeConsultParams) {
|
|
1631
1631
|
params.success =
|
|
1632
|
-
params && typeof params.success == "function" ? params.success :
|
|
1633
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1632
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1633
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1634
1634
|
|
|
1635
|
-
if (
|
|
1635
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1636
1636
|
params.fail({
|
|
1637
1637
|
success: false,
|
|
1638
1638
|
message: "initialization not complete!"
|
|
@@ -1640,7 +1640,7 @@ export default class ueSoftphoneBeta {
|
|
|
1640
1640
|
return;
|
|
1641
1641
|
}
|
|
1642
1642
|
|
|
1643
|
-
if (
|
|
1643
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1644
1644
|
params.fail({
|
|
1645
1645
|
success: false,
|
|
1646
1646
|
message: "initialization not complete!"
|
|
@@ -1648,14 +1648,14 @@ export default class ueSoftphoneBeta {
|
|
|
1648
1648
|
return;
|
|
1649
1649
|
}
|
|
1650
1650
|
|
|
1651
|
-
const server =
|
|
1651
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1652
1652
|
|
|
1653
|
-
|
|
1653
|
+
ueSoftphone.request(server + "/call/api/call/consult/resume", {
|
|
1654
1654
|
verb: "POST",
|
|
1655
1655
|
body: params,
|
|
1656
|
-
loginToken:
|
|
1657
|
-
sessionId:
|
|
1658
|
-
accountId:
|
|
1656
|
+
loginToken: ueSoftphone.loginToken,
|
|
1657
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1658
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1659
1659
|
encryptionAlgorithm,
|
|
1660
1660
|
encryptionFields,
|
|
1661
1661
|
success: (res: any) => {
|
|
@@ -1678,10 +1678,10 @@ export default class ueSoftphoneBeta {
|
|
|
1678
1678
|
// 咨询转接
|
|
1679
1679
|
consultTransfer(params: consultTransferParams) {
|
|
1680
1680
|
params.success =
|
|
1681
|
-
params && typeof params.success == "function" ? params.success :
|
|
1682
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1681
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1682
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1683
1683
|
|
|
1684
|
-
if (
|
|
1684
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1685
1685
|
params.fail({
|
|
1686
1686
|
success: false,
|
|
1687
1687
|
message: "initialization not complete!"
|
|
@@ -1689,7 +1689,7 @@ export default class ueSoftphoneBeta {
|
|
|
1689
1689
|
return;
|
|
1690
1690
|
}
|
|
1691
1691
|
|
|
1692
|
-
if (
|
|
1692
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1693
1693
|
params.fail({
|
|
1694
1694
|
success: false,
|
|
1695
1695
|
message: "initialization not complete!"
|
|
@@ -1697,14 +1697,14 @@ export default class ueSoftphoneBeta {
|
|
|
1697
1697
|
return;
|
|
1698
1698
|
}
|
|
1699
1699
|
|
|
1700
|
-
const server =
|
|
1700
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1701
1701
|
|
|
1702
|
-
|
|
1702
|
+
ueSoftphone.request(server + "/call/api/call/consult/transfer", {
|
|
1703
1703
|
verb: "POST",
|
|
1704
1704
|
body: params,
|
|
1705
|
-
loginToken:
|
|
1706
|
-
sessionId:
|
|
1707
|
-
accountId:
|
|
1705
|
+
loginToken: ueSoftphone.loginToken,
|
|
1706
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1707
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1708
1708
|
encryptionAlgorithm,
|
|
1709
1709
|
encryptionFields,
|
|
1710
1710
|
success: (res: any) => {
|
|
@@ -1727,10 +1727,10 @@ export default class ueSoftphoneBeta {
|
|
|
1727
1727
|
// 三方
|
|
1728
1728
|
threeWayCall(params: threeWayCallParams) {
|
|
1729
1729
|
params.success =
|
|
1730
|
-
params && typeof params.success == "function" ? params.success :
|
|
1731
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1730
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1731
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1732
1732
|
|
|
1733
|
-
if (
|
|
1733
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1734
1734
|
params.fail({
|
|
1735
1735
|
success: false,
|
|
1736
1736
|
message: "initialization not complete!"
|
|
@@ -1738,7 +1738,7 @@ export default class ueSoftphoneBeta {
|
|
|
1738
1738
|
return;
|
|
1739
1739
|
}
|
|
1740
1740
|
|
|
1741
|
-
if (
|
|
1741
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1742
1742
|
params.fail({
|
|
1743
1743
|
success: false,
|
|
1744
1744
|
message: "initialization not complete!"
|
|
@@ -1746,14 +1746,14 @@ export default class ueSoftphoneBeta {
|
|
|
1746
1746
|
return;
|
|
1747
1747
|
}
|
|
1748
1748
|
|
|
1749
|
-
const server =
|
|
1749
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1750
1750
|
|
|
1751
|
-
|
|
1751
|
+
ueSoftphone.request(server + "/call/api/call/threeway", {
|
|
1752
1752
|
verb: "POST",
|
|
1753
1753
|
body: params,
|
|
1754
|
-
loginToken:
|
|
1755
|
-
sessionId:
|
|
1756
|
-
accountId:
|
|
1754
|
+
loginToken: ueSoftphone.loginToken,
|
|
1755
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1756
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1757
1757
|
encryptionAlgorithm,
|
|
1758
1758
|
encryptionFields,
|
|
1759
1759
|
success: (res: any) => {
|
|
@@ -1776,10 +1776,10 @@ export default class ueSoftphoneBeta {
|
|
|
1776
1776
|
// 转满意度
|
|
1777
1777
|
evaluate(params: satisfactionParams) {
|
|
1778
1778
|
params.success =
|
|
1779
|
-
params && typeof params.success == "function" ? params.success :
|
|
1780
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1779
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1780
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1781
1781
|
|
|
1782
|
-
if (
|
|
1782
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1783
1783
|
params.fail({
|
|
1784
1784
|
success: false,
|
|
1785
1785
|
message: "initialization not complete!"
|
|
@@ -1787,7 +1787,7 @@ export default class ueSoftphoneBeta {
|
|
|
1787
1787
|
return;
|
|
1788
1788
|
}
|
|
1789
1789
|
|
|
1790
|
-
if (
|
|
1790
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1791
1791
|
params.fail({
|
|
1792
1792
|
success: false,
|
|
1793
1793
|
message: "initialization not complete!"
|
|
@@ -1802,14 +1802,14 @@ export default class ueSoftphoneBeta {
|
|
|
1802
1802
|
return;
|
|
1803
1803
|
}
|
|
1804
1804
|
|
|
1805
|
-
const server =
|
|
1805
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1806
1806
|
|
|
1807
|
-
|
|
1807
|
+
ueSoftphone.request(server + "/call/api/call/evaluate", {
|
|
1808
1808
|
verb: "POST",
|
|
1809
1809
|
body: params,
|
|
1810
|
-
loginToken:
|
|
1811
|
-
sessionId:
|
|
1812
|
-
accountId:
|
|
1810
|
+
loginToken: ueSoftphone.loginToken,
|
|
1811
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1812
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1813
1813
|
encryptionAlgorithm,
|
|
1814
1814
|
encryptionFields,
|
|
1815
1815
|
success: (res: any) => {
|
|
@@ -1831,10 +1831,10 @@ export default class ueSoftphoneBeta {
|
|
|
1831
1831
|
},
|
|
1832
1832
|
meeting(params: meetingParams) {
|
|
1833
1833
|
params.success =
|
|
1834
|
-
params && typeof params.success == "function" ? params.success :
|
|
1835
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1834
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1835
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1836
1836
|
|
|
1837
|
-
if (
|
|
1837
|
+
if (ueSoftphone.loginToken === null || ueSoftphone.loginToken === undefined) {
|
|
1838
1838
|
params.fail({
|
|
1839
1839
|
success: false,
|
|
1840
1840
|
message: "initialization not complete!"
|
|
@@ -1842,7 +1842,7 @@ export default class ueSoftphoneBeta {
|
|
|
1842
1842
|
return;
|
|
1843
1843
|
}
|
|
1844
1844
|
|
|
1845
|
-
if (
|
|
1845
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1846
1846
|
params.fail({
|
|
1847
1847
|
success: false,
|
|
1848
1848
|
message: "initialization not complete!"
|
|
@@ -1857,17 +1857,17 @@ export default class ueSoftphoneBeta {
|
|
|
1857
1857
|
return;
|
|
1858
1858
|
}
|
|
1859
1859
|
|
|
1860
|
-
const server =
|
|
1860
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1861
1861
|
|
|
1862
|
-
|
|
1862
|
+
ueSoftphone.request(server + "/call/api/call/meeting", {
|
|
1863
1863
|
verb: "POST",
|
|
1864
1864
|
body: {
|
|
1865
1865
|
meetingType: "phone",
|
|
1866
1866
|
number: params.number
|
|
1867
1867
|
},
|
|
1868
|
-
loginToken:
|
|
1869
|
-
sessionId:
|
|
1870
|
-
accountId:
|
|
1868
|
+
loginToken: ueSoftphone.loginToken,
|
|
1869
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1870
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1871
1871
|
encryptionAlgorithm,
|
|
1872
1872
|
encryptionFields,
|
|
1873
1873
|
success: (res: any) => {
|
|
@@ -1897,8 +1897,8 @@ export default class ueSoftphoneBeta {
|
|
|
1897
1897
|
async switchLoginType(params: UpdateLoginTypeParams) {
|
|
1898
1898
|
let loginNumber: any = null;
|
|
1899
1899
|
params.success =
|
|
1900
|
-
params && typeof params.success == "function" ? params.success :
|
|
1901
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1900
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1901
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1902
1902
|
if (params.loginType === null || params.loginType === undefined) {
|
|
1903
1903
|
params.fail({
|
|
1904
1904
|
success: false,
|
|
@@ -1906,7 +1906,7 @@ export default class ueSoftphoneBeta {
|
|
|
1906
1906
|
});
|
|
1907
1907
|
return;
|
|
1908
1908
|
}
|
|
1909
|
-
if (
|
|
1909
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1910
1910
|
params.fail({
|
|
1911
1911
|
success: false,
|
|
1912
1912
|
message: "initialization not complete!"
|
|
@@ -1917,7 +1917,7 @@ export default class ueSoftphoneBeta {
|
|
|
1917
1917
|
loginNumber = params.loginNumber;
|
|
1918
1918
|
}
|
|
1919
1919
|
if (params.loginType === "PSTN") {
|
|
1920
|
-
loginNumber = loginNumber ? loginNumber :
|
|
1920
|
+
loginNumber = loginNumber ? loginNumber : ueSoftphone.agentInfo.mobile;
|
|
1921
1921
|
if (!loginNumber) {
|
|
1922
1922
|
alert("请给座席绑定手机号,或者传入号码参数!");
|
|
1923
1923
|
params.fail({
|
|
@@ -1928,18 +1928,18 @@ export default class ueSoftphoneBeta {
|
|
|
1928
1928
|
}
|
|
1929
1929
|
}
|
|
1930
1930
|
if (params.loginType === "SIP") {
|
|
1931
|
-
loginNumber = loginNumber ? loginNumber :
|
|
1931
|
+
loginNumber = loginNumber ? loginNumber : ueSoftphone.agentInfo.sipNumber;
|
|
1932
1932
|
}
|
|
1933
1933
|
if (params.loginType === "WEBRTC") {
|
|
1934
|
-
loginNumber =
|
|
1934
|
+
loginNumber = ueSoftphone.agentInfo.webrtcSipNumber;
|
|
1935
1935
|
}
|
|
1936
1936
|
|
|
1937
|
-
const server =
|
|
1937
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
1938
1938
|
const query: UpdateLoginTypeParams = {
|
|
1939
1939
|
loginType: params.loginType,
|
|
1940
1940
|
loginNumber: loginNumber
|
|
1941
1941
|
};
|
|
1942
|
-
const options =
|
|
1942
|
+
const options = ueSoftphone.initOptions;
|
|
1943
1943
|
let audioObj;
|
|
1944
1944
|
const isStrongHint = true;
|
|
1945
1945
|
// typeof options.isStrongHint === "boolean" ? options.isStrongHint : true;
|
|
@@ -1950,12 +1950,12 @@ export default class ueSoftphoneBeta {
|
|
|
1950
1950
|
console.log(error);
|
|
1951
1951
|
}
|
|
1952
1952
|
}
|
|
1953
|
-
|
|
1953
|
+
ueSoftphone.request(server + "/call/api/agent/v1/login-type/change", {
|
|
1954
1954
|
verb: "POST",
|
|
1955
1955
|
body: query,
|
|
1956
|
-
loginToken:
|
|
1957
|
-
sessionId:
|
|
1958
|
-
accountId:
|
|
1956
|
+
loginToken: ueSoftphone.loginToken,
|
|
1957
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1958
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
1959
1959
|
success: async (res: any) => {
|
|
1960
1960
|
if (res.success) {
|
|
1961
1961
|
(params.success as Function)({
|
|
@@ -1963,17 +1963,17 @@ export default class ueSoftphoneBeta {
|
|
|
1963
1963
|
message: "updateLoginType success",
|
|
1964
1964
|
...audioObj
|
|
1965
1965
|
});
|
|
1966
|
-
|
|
1967
|
-
|
|
1966
|
+
ueSoftphone.agentInfo.loginType = params.loginType;
|
|
1967
|
+
ueSoftphone.initOptions.loginType= params.loginType;
|
|
1968
1968
|
if (params.loginType === "WEBRTC") {
|
|
1969
1969
|
that._webPhoneApi().connect();
|
|
1970
1970
|
} else if (params.loginType === "PSTN") {
|
|
1971
|
-
await
|
|
1971
|
+
await ueSoftphone.request(server + "/platform/action/updateCallConfig", {
|
|
1972
1972
|
verb: "POST",
|
|
1973
1973
|
body: { agentCallConfig: {}, mobile: params.loginNumber! },
|
|
1974
|
-
loginToken:
|
|
1975
|
-
sessionId:
|
|
1976
|
-
accountId:
|
|
1974
|
+
loginToken: ueSoftphone.loginToken,
|
|
1975
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
1976
|
+
accountId: ueSoftphone.agentInfo.accountId
|
|
1977
1977
|
});
|
|
1978
1978
|
that._webPhoneApi().disconnect();
|
|
1979
1979
|
} else {
|
|
@@ -1993,21 +1993,21 @@ export default class ueSoftphoneBeta {
|
|
|
1993
1993
|
// 获取电话条的所有状态
|
|
1994
1994
|
findPhoneBarList(params: GetAgentPhoneBarParams) {
|
|
1995
1995
|
params.success =
|
|
1996
|
-
params && typeof params.success == "function" ? params.success :
|
|
1997
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
1998
|
-
if (
|
|
1996
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
1997
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
1998
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
1999
1999
|
params.fail({
|
|
2000
2000
|
success: false,
|
|
2001
2001
|
message: "initialization not complete!"
|
|
2002
2002
|
});
|
|
2003
2003
|
return;
|
|
2004
2004
|
}
|
|
2005
|
-
const server =
|
|
2006
|
-
|
|
2005
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2006
|
+
ueSoftphone.request(server + "/call/api/phone/bar/all", {
|
|
2007
2007
|
verb: "GET",
|
|
2008
|
-
loginToken:
|
|
2009
|
-
sessionId:
|
|
2010
|
-
accountId:
|
|
2008
|
+
loginToken: ueSoftphone.loginToken,
|
|
2009
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
2010
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
2011
2011
|
success: (res: any) => {
|
|
2012
2012
|
if (res.success) {
|
|
2013
2013
|
let dataList: any = [];
|
|
@@ -2033,8 +2033,8 @@ export default class ueSoftphoneBeta {
|
|
|
2033
2033
|
// 更新座席的电话条状态
|
|
2034
2034
|
switchPhoneBar(params: UpdateAgentStatusParams) {
|
|
2035
2035
|
params.success =
|
|
2036
|
-
params && typeof params.success == "function" ? params.success :
|
|
2037
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
2036
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
2037
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
2038
2038
|
if (params.stateNumber === null || params.stateNumber === undefined) {
|
|
2039
2039
|
params.fail({
|
|
2040
2040
|
success: false,
|
|
@@ -2042,24 +2042,24 @@ export default class ueSoftphoneBeta {
|
|
|
2042
2042
|
});
|
|
2043
2043
|
return;
|
|
2044
2044
|
}
|
|
2045
|
-
if (
|
|
2045
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
2046
2046
|
params.fail({
|
|
2047
2047
|
success: false,
|
|
2048
2048
|
message: "initialization not complete!"
|
|
2049
2049
|
});
|
|
2050
2050
|
return;
|
|
2051
2051
|
}
|
|
2052
|
-
const server =
|
|
2052
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2053
2053
|
const query = {
|
|
2054
2054
|
stateNumber: params.stateNumber,
|
|
2055
|
-
accountId:
|
|
2056
|
-
agentNumber:
|
|
2055
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
2056
|
+
agentNumber: ueSoftphone.agentInfo.agentNumber
|
|
2057
2057
|
};
|
|
2058
|
-
|
|
2058
|
+
ueSoftphone.request(server + "/call/api/agent/status/switch", {
|
|
2059
2059
|
verb: "POST",
|
|
2060
2060
|
body: query,
|
|
2061
|
-
loginToken:
|
|
2062
|
-
sessionId:
|
|
2061
|
+
loginToken: ueSoftphone.loginToken,
|
|
2062
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
2063
2063
|
success: (res: any) => {
|
|
2064
2064
|
if (res.success) {
|
|
2065
2065
|
(params.success as Function)({
|
|
@@ -2078,9 +2078,9 @@ export default class ueSoftphoneBeta {
|
|
|
2078
2078
|
// 退出登录
|
|
2079
2079
|
logout(params: AgentOfflineParams) {
|
|
2080
2080
|
params.success =
|
|
2081
|
-
params && typeof params.success == "function" ? params.success :
|
|
2082
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
2083
|
-
if (
|
|
2081
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
2082
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
2083
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
2084
2084
|
params.fail({
|
|
2085
2085
|
success: false,
|
|
2086
2086
|
message: "initialization not complete!"
|
|
@@ -2090,22 +2090,22 @@ export default class ueSoftphoneBeta {
|
|
|
2090
2090
|
if (params.toAnswerOffline === null || params.toAnswerOffline === undefined) {
|
|
2091
2091
|
params.toAnswerOffline = "1";
|
|
2092
2092
|
}
|
|
2093
|
-
const server =
|
|
2093
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2094
2094
|
const query = {
|
|
2095
2095
|
toAnswerOffline: params.toAnswerOffline
|
|
2096
2096
|
};
|
|
2097
|
-
|
|
2097
|
+
ueSoftphone.request(server + "/call/api/sdk/agent/logout", {
|
|
2098
2098
|
verb: "POST",
|
|
2099
2099
|
body: query,
|
|
2100
|
-
loginToken:
|
|
2101
|
-
sessionId:
|
|
2102
|
-
accountId:
|
|
2100
|
+
loginToken: ueSoftphone.loginToken,
|
|
2101
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
2102
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
2103
2103
|
success: (res: any) => {
|
|
2104
2104
|
if (res.success) {
|
|
2105
2105
|
if (params) {
|
|
2106
|
-
|
|
2107
|
-
if (
|
|
2108
|
-
|
|
2106
|
+
ueSoftphone.Socketinstance.disconnect();
|
|
2107
|
+
if (ueSoftphone.agentInfo.loginType === "WEBRTC") {
|
|
2108
|
+
ueSoftphone.webPhone.disconnect();
|
|
2109
2109
|
}
|
|
2110
2110
|
(params.success as Function)({
|
|
2111
2111
|
success: true
|
|
@@ -2126,22 +2126,22 @@ export default class ueSoftphoneBeta {
|
|
|
2126
2126
|
// 获取技能组中空闲的座席(用于转接和咨询)
|
|
2127
2127
|
findIdleAgentsForQueue(params: GetQueueOnlineAgentsParams) {
|
|
2128
2128
|
params.success =
|
|
2129
|
-
params && typeof params.success == "function" ? params.success :
|
|
2130
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
2131
|
-
if (
|
|
2129
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
2130
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
2131
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
2132
2132
|
params.fail({
|
|
2133
2133
|
success: false,
|
|
2134
2134
|
message: "initialization not complete!"
|
|
2135
2135
|
});
|
|
2136
2136
|
return;
|
|
2137
2137
|
}
|
|
2138
|
-
const server =
|
|
2139
|
-
|
|
2138
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2139
|
+
ueSoftphone.request(server + "/call/api/queue/acountFreeAgent/find", {
|
|
2140
2140
|
verb: "POST",
|
|
2141
2141
|
body: {},
|
|
2142
|
-
loginToken:
|
|
2143
|
-
sessionId:
|
|
2144
|
-
accountId:
|
|
2142
|
+
loginToken: ueSoftphone.loginToken,
|
|
2143
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
2144
|
+
accountId: ueSoftphone.agentInfo.accountId,
|
|
2145
2145
|
success: (res: any) => {
|
|
2146
2146
|
if (res.success) {
|
|
2147
2147
|
if (params) {
|
|
@@ -2165,21 +2165,21 @@ export default class ueSoftphoneBeta {
|
|
|
2165
2165
|
// 切换sip接听方式的时候,拉取当前可绑定的sip号列表
|
|
2166
2166
|
getAvailableSipNumberList(params: any) {
|
|
2167
2167
|
params.success =
|
|
2168
|
-
params && typeof params.success == "function" ? params.success :
|
|
2169
|
-
params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
2170
|
-
if (
|
|
2168
|
+
params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
2169
|
+
params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
2170
|
+
if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
2171
2171
|
params.fail({
|
|
2172
2172
|
success: false,
|
|
2173
2173
|
message: "initialization not complete!"
|
|
2174
2174
|
});
|
|
2175
2175
|
return;
|
|
2176
2176
|
}
|
|
2177
|
-
const server =
|
|
2178
|
-
|
|
2177
|
+
const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2178
|
+
ueSoftphone.request(server + "/call/api/sip/avaliable/query", {
|
|
2179
2179
|
verb: "POST",
|
|
2180
2180
|
body: {},
|
|
2181
|
-
loginToken:
|
|
2182
|
-
sessionId:
|
|
2181
|
+
loginToken: ueSoftphone.loginToken,
|
|
2182
|
+
sessionId: ueSoftphone.agentInfo._id,
|
|
2183
2183
|
success: (res: any) => {
|
|
2184
2184
|
if (res.success && res.data) {
|
|
2185
2185
|
let dataList: any = [];
|
|
@@ -2207,9 +2207,9 @@ export default class ueSoftphoneBeta {
|
|
|
2207
2207
|
// // 设置离线接听(手机和sip话机方式可行)
|
|
2208
2208
|
// setAnswerOffline(params: AgentOfflineParams) {
|
|
2209
2209
|
// params.success =
|
|
2210
|
-
// params && typeof params.success == "function" ? params.success :
|
|
2211
|
-
// params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
2212
|
-
// if (
|
|
2210
|
+
// params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
2211
|
+
// params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
2212
|
+
// if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
2213
2213
|
// params.fail({
|
|
2214
2214
|
// success: false,
|
|
2215
2215
|
// message: "initialization not complete!"
|
|
@@ -2219,16 +2219,16 @@ export default class ueSoftphoneBeta {
|
|
|
2219
2219
|
// if (params.toAnswerOffline === null || params.toAnswerOffline === undefined) {
|
|
2220
2220
|
// params.toAnswerOffline = "1";
|
|
2221
2221
|
// }
|
|
2222
|
-
// const server =
|
|
2222
|
+
// const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2223
2223
|
// const query = {
|
|
2224
2224
|
// toAnswerOffline: params.toAnswerOffline
|
|
2225
2225
|
// };
|
|
2226
|
-
//
|
|
2226
|
+
// ueSoftphone.request(server + "/call/sdk/v1/call/offline/answer", {
|
|
2227
2227
|
// verb: "POST",
|
|
2228
2228
|
// body: query,
|
|
2229
|
-
// loginToken:
|
|
2230
|
-
// sessionId:
|
|
2231
|
-
// accountId:
|
|
2229
|
+
// loginToken: ueSoftphone.loginToken,
|
|
2230
|
+
// sessionId: ueSoftphone.agentInfo._id,
|
|
2231
|
+
// accountId: ueSoftphone.agentInfo.accountId,
|
|
2232
2232
|
// success: (res: any) => {
|
|
2233
2233
|
// if (res.success) {
|
|
2234
2234
|
// if (params) {
|
|
@@ -2252,9 +2252,9 @@ export default class ueSoftphoneBeta {
|
|
|
2252
2252
|
// // 获取IVR语音导航列表(用于转IVR的时候可选择转哪个ivr)
|
|
2253
2253
|
// getIvrList(params: getIvrListParams) {
|
|
2254
2254
|
// params.success =
|
|
2255
|
-
// params && typeof params.success == "function" ? params.success :
|
|
2256
|
-
// params.fail = params && typeof params.fail == "function" ? params.fail :
|
|
2257
|
-
// if (
|
|
2255
|
+
// params && typeof params.success == "function" ? params.success : ueSoftphone.noop;
|
|
2256
|
+
// params.fail = params && typeof params.fail == "function" ? params.fail : ueSoftphone.noop;
|
|
2257
|
+
// if (ueSoftphone.agentInfo === null || ueSoftphone.agentInfo === undefined) {
|
|
2258
2258
|
// params.fail({
|
|
2259
2259
|
// success: false,
|
|
2260
2260
|
// message: "initialization not complete!"
|
|
@@ -2268,13 +2268,13 @@ export default class ueSoftphoneBeta {
|
|
|
2268
2268
|
// });
|
|
2269
2269
|
// return;
|
|
2270
2270
|
// }
|
|
2271
|
-
// const server =
|
|
2272
|
-
//
|
|
2271
|
+
// const server = ueSoftphone.initOptions.server || ueSoftphone.callApiUrl;
|
|
2272
|
+
// ueSoftphone.request(server + "/call/sdk/v1/call/general/query", {
|
|
2273
2273
|
// verb: "POST",
|
|
2274
2274
|
// body: params,
|
|
2275
|
-
// loginToken:
|
|
2276
|
-
// sessionId:
|
|
2277
|
-
// accountId:
|
|
2275
|
+
// loginToken: ueSoftphone.loginToken,
|
|
2276
|
+
// sessionId: ueSoftphone.agentInfo._id,
|
|
2277
|
+
// accountId: ueSoftphone.agentInfo.accountId,
|
|
2278
2278
|
// success: (res: any) => {
|
|
2279
2279
|
// if (res.success) {
|
|
2280
2280
|
// if (params) {
|
|
@@ -2301,27 +2301,27 @@ export default class ueSoftphoneBeta {
|
|
|
2301
2301
|
return {
|
|
2302
2302
|
// 接听
|
|
2303
2303
|
accept() {
|
|
2304
|
-
|
|
2304
|
+
ueSoftphone.webPhone.accept();
|
|
2305
2305
|
},
|
|
2306
2306
|
// 注册设备,链接webrtc
|
|
2307
2307
|
connect() {
|
|
2308
|
-
if (!
|
|
2309
|
-
|
|
2308
|
+
if (!ueSoftphone.webPhone || !this.isConnected()) {
|
|
2309
|
+
ueSoftphone.initWebrtcEvent(ueSoftphone.agentextras);
|
|
2310
2310
|
}
|
|
2311
2311
|
},
|
|
2312
2312
|
// 注销设备,跟webrtc断开链接
|
|
2313
2313
|
disconnect() {
|
|
2314
|
-
if (
|
|
2315
|
-
|
|
2314
|
+
if (ueSoftphone.webPhone && this.isConnected()) {
|
|
2315
|
+
ueSoftphone.webPhone.disconnect();
|
|
2316
2316
|
}
|
|
2317
2317
|
},
|
|
2318
2318
|
// 检测设备是否有链接上
|
|
2319
2319
|
isConnected() {
|
|
2320
|
-
return
|
|
2320
|
+
return ueSoftphone.webPhone.isConnected();
|
|
2321
2321
|
},
|
|
2322
2322
|
// 发送DTMF 可与demo中的软电话拨号盘结合使用
|
|
2323
2323
|
sendDTMF(tone: string) {
|
|
2324
|
-
|
|
2324
|
+
ueSoftphone.webPhone.sendDTMF(tone);
|
|
2325
2325
|
}
|
|
2326
2326
|
};
|
|
2327
2327
|
};
|