@94ai/softphone 5.0.12 → 5.0.13
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/html-softphone-demo/embed-ui/index.html +22 -0
- package/html-softphone-demo/embed-ui/softphone.js +22 -10
- package/html-softphone-demo/index.html +41 -30
- package/html-softphone-demo/micro-call-ui/index.html +33 -6
- package/html-softphone-demo/softphone.umd.min.js +2 -1
- package/lib/softphone.cjs.min.cjs +1 -1
- package/lib/softphone.esm-bundler.min.mjs +1 -1
- package/lib/softphone.umd.min.js +2 -1
- package/package.json +1 -1
|
@@ -41,9 +41,14 @@
|
|
|
41
41
|
<script src="./util.js"></script>
|
|
42
42
|
<script src="./softphone.js"></script>
|
|
43
43
|
<script>
|
|
44
|
+
// 国内
|
|
44
45
|
const agentTag1 = 'zoujh-test'
|
|
45
46
|
const appKey1 = '032d44009bff1752'
|
|
46
47
|
const appSecret1 = '4c7304c94c5e8725613516d4d6db679b'
|
|
48
|
+
// 海外
|
|
49
|
+
// const agentId = '2357'
|
|
50
|
+
// const appKey1 = 'a52e61f0d9ff1527'
|
|
51
|
+
// const appSecret1 = '7ed1d78fbe214ba8b8e6a2dc9c6955aa'
|
|
47
52
|
|
|
48
53
|
/**
|
|
49
54
|
👈 拿到实例后可以手动触发软电话实例的各种动作,如签入,签出,接听,忽略,挂断等等,注意这个实例不是软电话实例,是链接软电话通讯的实例
|
|
@@ -54,6 +59,19 @@ const nfSoftPhone1 = (new SoftphoneManager()).initSoftphone({ // 👈 当多实
|
|
|
54
59
|
ancestorOrigin: 'nf-softphone1', // origin,ancestorOrigin,destinationOrigin具体含义参见下文,如果是单实例,可以写死origin=ai-softphone&destinationOrigin=nf-softphone&ancestorOrigin=nf-softphone
|
|
55
60
|
destinationOrigin: 'nf-softphone1',
|
|
56
61
|
|
|
62
|
+
/**
|
|
63
|
+
* start - 海外特有参数
|
|
64
|
+
*/
|
|
65
|
+
// sgGateway: '1',
|
|
66
|
+
// sgBase: '1',
|
|
67
|
+
// sgOpen: '1',
|
|
68
|
+
// sgDomain: '1',
|
|
69
|
+
// env: 'sg',
|
|
70
|
+
/**
|
|
71
|
+
* end - 海外特有参数
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
// agentId, // 👈 坐席唯一标志
|
|
57
75
|
agentTag: agentTag1, // 👈 坐席唯一标志
|
|
58
76
|
appKey: appKey1, // 👈 企业appKey
|
|
59
77
|
appSecret: appSecret1,
|
|
@@ -72,6 +90,10 @@ const nfSoftPhone1 = (new SoftphoneManager()).initSoftphone({ // 👈 当多实
|
|
|
72
90
|
softphoneSendDtmfCallBack: (data) => {console.log('softphone-send-dtmf')},// 👈 转人工回调
|
|
73
91
|
softphoneConnectRegisteredCallBack: (data) => {console.log('softphone-connect-registered')},// 👈 动态绑定动作完成回调(在这之后才能执行动作类总线通讯)
|
|
74
92
|
});
|
|
93
|
+
|
|
94
|
+
// setTimeout(() => {
|
|
95
|
+
// nfSoftPhone1.destroy()
|
|
96
|
+
// }, 3000)
|
|
75
97
|
</script>
|
|
76
98
|
</body>
|
|
77
99
|
</html>
|
|
@@ -241,7 +241,11 @@ class SoftphoneManager {
|
|
|
241
241
|
Object.keys(this.option.instanceMap).forEach(key => {
|
|
242
242
|
const el = document.getElementById(key)
|
|
243
243
|
if (el && el.parentNode) {
|
|
244
|
-
|
|
244
|
+
if (el instanceof HTMLIFrameElement) {
|
|
245
|
+
el.remove()
|
|
246
|
+
} else {
|
|
247
|
+
el.parentNode.removeChild(el)
|
|
248
|
+
}
|
|
245
249
|
}
|
|
246
250
|
})
|
|
247
251
|
}
|
|
@@ -450,15 +454,23 @@ class SoftphoneManager {
|
|
|
450
454
|
this.timer = undefined
|
|
451
455
|
}
|
|
452
456
|
|
|
453
|
-
destroy = () => {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
457
|
+
destroy = async () => {
|
|
458
|
+
return new Promise((resolve) => {
|
|
459
|
+
this.disconnect()
|
|
460
|
+
let timer = setTimeout(() => {
|
|
461
|
+
clearTimeout(timer)
|
|
462
|
+
timer = undefined
|
|
463
|
+
window.removeEventListener('message', this.handlingCommunication, false);
|
|
464
|
+
if (this.option.scrollview) {
|
|
465
|
+
document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScroll)
|
|
466
|
+
document.querySelector(this.option.scrollview)?.removeEventListener('scroll', this.handlingScrollTransparent)
|
|
467
|
+
}
|
|
468
|
+
this.removeCssCode()
|
|
469
|
+
this.handlerDomRemove()
|
|
470
|
+
this.removeTimer()
|
|
471
|
+
resolve()
|
|
472
|
+
})
|
|
473
|
+
})
|
|
462
474
|
}
|
|
463
475
|
}
|
|
464
476
|
|
|
@@ -347,7 +347,11 @@ document.addEventListener('DOMContentLoaded', async (event) => {
|
|
|
347
347
|
// appSecret: '7ed1d78fbe214ba8b8e6a2dc9c6955aa', // 海外生产线 企业维度定位 这里直接使用appSecret做演示
|
|
348
348
|
|
|
349
349
|
// logLevel: 'debug', // 日志等级,默认error
|
|
350
|
-
|
|
350
|
+
openXhrIntercept(xhr) {
|
|
351
|
+
// xhr.setRequestHeader('language', 'es-ES')
|
|
352
|
+
xhr.setRequestHeader('language', 'zh-CN')
|
|
353
|
+
// xhr.setRequestHeader('language', 'en-US')
|
|
354
|
+
},
|
|
351
355
|
agentTag: '15018707394', // 国内生产线 坐席维度定位
|
|
352
356
|
appKey: '032d44009bff1752', // 国内生产线 企业维度定位
|
|
353
357
|
appSecret: '4c7304c94c5e8725613516d4d6db679b', // 国内生产线 企业维度定位 这里直接使用appSecret做演示
|
|
@@ -658,7 +662,7 @@ document.addEventListener('DOMContentLoaded', async (event) => {
|
|
|
658
662
|
},
|
|
659
663
|
async onReject (info) { //👈 转人工响应超时或失败
|
|
660
664
|
alert('转人工响应失败:' + info.message?.statusCode + ':' + info.message?.reasonPhrase)
|
|
661
|
-
reject(
|
|
665
|
+
reject(info.message.statusCode + ':' + info.message.reasonPhrase)
|
|
662
666
|
}
|
|
663
667
|
}
|
|
664
668
|
}) // 👈 一键转人工,await的下行代码被执行说明成功发出转人工信令
|
|
@@ -672,34 +676,41 @@ document.addEventListener('DOMContentLoaded', async (event) => {
|
|
|
672
676
|
/**
|
|
673
677
|
* 挂断
|
|
674
678
|
*/
|
|
675
|
-
const hangUpInvite = async () => {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
679
|
+
const hangUpInvite = async (reTry = false) => {
|
|
680
|
+
try {
|
|
681
|
+
await new Promise((resolve, reject) => {
|
|
682
|
+
const fn = async () => {
|
|
683
|
+
await userAgentManager.hangUpInvite({
|
|
684
|
+
scoutResponse: true, // 标识是手动挂断,手动挂断无需等待响应,信号成功发出立即重置会话状态。
|
|
685
|
+
byeOptions: {
|
|
686
|
+
requestDelegate: {
|
|
687
|
+
async onAccept (response) { // 👈 挂断响应成功
|
|
688
|
+
resolve(response)
|
|
689
|
+
},
|
|
690
|
+
onReject: async (response) => { // 👈 挂断响应超时或失败
|
|
691
|
+
if (typeof reTry !== 'boolean') { // 事件对象
|
|
692
|
+
await hangUpInvite(true)
|
|
693
|
+
}
|
|
694
|
+
// alert('挂断响应失败: ' + response?.message?.statusCode + ': ' + response?.message?.reasonPhrase) // 会话终止
|
|
695
|
+
reject(response?.message?.statusCode + ': ' + response?.message?.reasonPhrase)
|
|
696
|
+
}
|
|
688
697
|
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
})
|
|
698
|
+
},
|
|
699
|
+
}) // 👈 一键挂断, 下行代码执行,说明挂端信令成功发出
|
|
700
|
+
stopPhoneRings() // 暂停来电铃声,正常挂断不需要处理铃声(因为已经接听,会话已建立,才能挂断),这里做个兜底
|
|
701
|
+
ignore.disabled = true
|
|
702
|
+
answer.disabled = true
|
|
703
|
+
hangUp.disabled = true
|
|
704
|
+
localSoundDisconnection.disabled = true
|
|
705
|
+
remoteSoundDisconnection.disabled = true
|
|
706
|
+
localVoiceAccess.disabled = true
|
|
707
|
+
remoteSoundAccess.disabled = true
|
|
708
|
+
}
|
|
709
|
+
fn()
|
|
710
|
+
})
|
|
711
|
+
} catch (e) {
|
|
712
|
+
console.log(e.message, '======')
|
|
713
|
+
}
|
|
703
714
|
}
|
|
704
715
|
/**
|
|
705
716
|
* 忽略
|
|
@@ -729,7 +740,7 @@ document.addEventListener('DOMContentLoaded', async (event) => {
|
|
|
729
740
|
resolve(info)
|
|
730
741
|
},
|
|
731
742
|
onAckTimeout () { // 👈 接听响应失败
|
|
732
|
-
reject(
|
|
743
|
+
reject('接听响应失败')
|
|
733
744
|
}
|
|
734
745
|
}) // 👈 一键接听,下行代码被执行说明接听信令被成功发出
|
|
735
746
|
} catch (e) {
|
|
@@ -20,10 +20,14 @@ let nfSoftPhoneInstance
|
|
|
20
20
|
document.addEventListener('DOMContentLoaded', async (event) => {
|
|
21
21
|
let sign = ''
|
|
22
22
|
const timestamp = Date.now()
|
|
23
|
-
|
|
24
|
-
const agentTag = 'zoujh-test'
|
|
25
|
-
const appKey = '032d44009bff1752'
|
|
26
|
-
const appSecret = '4c7304c94c5e8725613516d4d6db679b'
|
|
23
|
+
// 国内
|
|
24
|
+
// const agentTag = 'zoujh-test'
|
|
25
|
+
// const appKey = '032d44009bff1752'
|
|
26
|
+
// const appSecret = '4c7304c94c5e8725613516d4d6db679b'
|
|
27
|
+
// 海外
|
|
28
|
+
const agentId = '2357'
|
|
29
|
+
const appKey = 'a52e61f0d9ff1527'
|
|
30
|
+
const appSecret = '7ed1d78fbe214ba8b8e6a2dc9c6955aa'
|
|
27
31
|
|
|
28
32
|
const str = appKey + timestamp
|
|
29
33
|
const sha1 = CryptoJS.HmacSHA1(str, appSecret)
|
|
@@ -40,14 +44,37 @@ document.addEventListener('DOMContentLoaded', async (event) => {
|
|
|
40
44
|
|
|
41
45
|
muteShow: '0', // 👈 屏蔽静音功能
|
|
42
46
|
|
|
43
|
-
agentTag, // 👈 坐席唯一标志
|
|
47
|
+
// agentTag, // 👈 坐席唯一标志
|
|
48
|
+
agentId, // 👈 坐席唯一标志
|
|
44
49
|
appKey, // 👈 企业appKey
|
|
45
50
|
sign, // 👈 授权sign
|
|
46
51
|
timestamp,
|
|
47
52
|
|
|
53
|
+
/**
|
|
54
|
+
* start - 海外特有参数
|
|
55
|
+
*/
|
|
56
|
+
sgGateway: '1',
|
|
57
|
+
sgBase: '1',
|
|
58
|
+
sgOpen: '1',
|
|
59
|
+
sgDomain: '1',
|
|
60
|
+
env: 'sg',
|
|
61
|
+
/**
|
|
62
|
+
* end - 海外特有参数
|
|
63
|
+
*/
|
|
64
|
+
|
|
48
65
|
extStatus: '1', // 👈 初始化是否处于小休状态, 非1 小休 1 在线
|
|
49
66
|
|
|
50
|
-
softphoneConnectCallBack: (data) => {
|
|
67
|
+
softphoneConnectCallBack: async (data) => {
|
|
68
|
+
console.log(await (await data.commonSoftphone.getUserAgentManager()).getAgentInfo())
|
|
69
|
+
// const userAgent = await data.commonSoftphone.getUserAgentManager()
|
|
70
|
+
// console.log(await userAgent.getAgentInfo())
|
|
71
|
+
// console.log(await userAgent.requestOpenApi({
|
|
72
|
+
// url: '/v1/agent/getAgent',
|
|
73
|
+
// data: {
|
|
74
|
+
// agentTag,
|
|
75
|
+
// }
|
|
76
|
+
// }))
|
|
77
|
+
}, // 👈 签入签出回调
|
|
51
78
|
softphoneCallRefreshCallBack: (data) => {console.log('softphone-call-refresh', data)}, // 👈 来电刷新来电记录列表回调
|
|
52
79
|
softphoneSeatStatusChangeCallBack: (data) => {console.log('softphone-seats-status-change', data)},// 👈 小休和在线切换回调
|
|
53
80
|
softphoneAcceptCallBack: (data) => {console.log('softphone-accept', data)},// 👈 接听回调
|