@94ai/softphone 6.0.5 → 6.0.6

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.
Files changed (46) hide show
  1. package/lib/softphone.umd.min.js +1 -1
  2. package/package.json +1 -1
  3. package/.yarnrc.yml +0 -19
  4. package/html-softphone-demo/CryptoJS.js +0 -3
  5. package/html-softphone-demo/README.md +0 -10
  6. package/html-softphone-demo/RootCA.pem +0 -20
  7. package/html-softphone-demo/WebrtcDiver.js +0 -320
  8. package/html-softphone-demo/antique_phone.mp3 +0 -0
  9. package/html-softphone-demo/cert.pem +0 -21
  10. package/html-softphone-demo/embed-ui/index.html +0 -123
  11. package/html-softphone-demo/embed-ui/softphone.js +0 -533
  12. package/html-softphone-demo/embed-ui/util.js +0 -123
  13. package/html-softphone-demo/fp.umd.min.js +0 -9
  14. package/html-softphone-demo/gg.xccjh.top.key +0 -27
  15. package/html-softphone-demo/gg.xccjh.top.pem +0 -61
  16. package/html-softphone-demo/index-channel.html +0 -904
  17. package/html-softphone-demo/index-local.html +0 -586
  18. package/html-softphone-demo/index-open.html +0 -617
  19. package/html-softphone-demo/index-switch-pcm.html +0 -613
  20. package/html-softphone-demo/index-test.html +0 -593
  21. package/html-softphone-demo/index-voice.html +0 -720
  22. package/html-softphone-demo/index.html +0 -1090
  23. package/html-softphone-demo/localhost.crt +0 -21
  24. package/html-softphone-demo/localhost.key +0 -28
  25. package/html-softphone-demo/micro-call-ui/CryptoJS.js +0 -3
  26. package/html-softphone-demo/micro-call-ui/draggable.html +0 -168
  27. package/html-softphone-demo/micro-call-ui/draggable.js +0 -1
  28. package/html-softphone-demo/micro-call-ui/index.html +0 -153
  29. package/html-softphone-demo/micro-call-ui/microphone.js +0 -824
  30. package/html-softphone-demo/micro-call-ui/qiankun.js +0 -2
  31. package/html-softphone-demo/micro-call-ui/util.js +0 -33
  32. package/html-softphone-demo/micro-call-ui/wujie.js +0 -3
  33. package/html-softphone-demo/pcm-player.js +0 -131
  34. package/html-softphone-demo/pcm-server/16bit-44100.pcm +0 -0
  35. package/html-softphone-demo/pcm-server/index.html +0 -110
  36. package/html-softphone-demo/pcm-server/server.js +0 -54
  37. package/html-softphone-demo/private.key +0 -28
  38. package/html-softphone-demo/softphone.umd.min.js +0 -2
  39. package/html-softphone-demo/tapd_35238004_base64_1695010473_859.gif +0 -0
  40. package/html-softphone-demo/test.html +0 -190
  41. package/html-softphone-demo/vue-esm-ui/common-ui.es.browser.js +0 -56545
  42. package/html-softphone-demo/vue-esm-ui/vue-esm.html +0 -2043
  43. package/html-softphone-demo/vue-sfc-ui/CryptoJS.js +0 -3
  44. package/html-softphone-demo/vue-sfc-ui/vue-sfc.html +0 -1858
  45. package/html-softphone-demo/vue-umd-ui/common-ui.umd.browser.js +0 -338
  46. package/html-softphone-demo/vue-umd-ui/vue-umd.html +0 -1978
@@ -1,593 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport"
6
- content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
7
- <title>softphone</title>
8
- <style>
9
- #softphone-app {
10
- padding-top: 50px;
11
- overflow: hidden;
12
- }
13
- </style>
14
- </head>
15
- <body>
16
- <div id="softphone-app">
17
- <div style="float: left;margin-left: 20px">
18
- <div style="margin-bottom: 15px">
19
- 一、当前坐席信息:
20
- </div>
21
- <pre id="info"></pre>
22
- <div>
23
- 2. 当前坐席交流传递到远端的音量大小:<span id="volumn">0.00</span>
24
- <div>- (强度比例0.00~1.00,用以实现如下音量反馈效果)</div>
25
- <img src="./tapd_35238004_base64_1695010473_859.gif" style="width: 460px" />
26
- </div>
27
- <div style="margin-bottom: 15px">
28
- 3. 当前浏览器状态(通过权限网络检测获取):
29
- </div>
30
- <pre id="browserSoftphoneEnv"></pre>
31
- </div>
32
- <div style="float: left;margin-left: 10px">
33
- <div style="margin-bottom: 15px">
34
- 二、调试步骤:
35
- </div>
36
- <div>1. 获取坐席是否在线
37
- <div>
38
- - agentStatus === 1 -> 在线
39
- </div>
40
- <div>
41
- - agentStatus === 3 -> 小休
42
- </div>
43
- <div>
44
- - tip: 能外呼的条件是:
45
- <div style="margin-left: 20px;">
46
- <div>
47
- 1. 软电话签入
48
- </div>
49
- <div>
50
- 2. 坐席在线
51
- </div>
52
- <div>
53
- 3. 同时确保坐席所在企业配置 【坐席外呼依赖】配置项 是【标识】 (默认是【登录】)
54
- </div>
55
- <div style="margin-left: 20px;">
56
- - 配置项 【登录】:只有登录了94决策系统才可外呼。
57
- </div>
58
- <div style="margin-left: 30px;">
59
- (tip: 如果不确定联系94运维在管理后台查看以及配置)
60
- </div>
61
- </div>
62
- </div>
63
-
64
- </div>
65
- <div>2. 设置坐席在线</div>
66
- <div>3. 连接外呼服务器(软电话签入)</div>
67
- <div>4. 手动呼叫或任务外呼</div>
68
- <div>- 手动呼叫,外呼服务器会先呼叫坐席,坐席接听后才会正式呼叫用户</div>
69
- <div>- 任务外呼,外呼服务器会先呼叫用户,用户接听后才会正式呼叫坐席,坐席接听前有ai和用户对话</div>
70
- <div>5. 接听 </div>
71
- <div>6. 转人工(根据任务的配置:是否是监听任务,手动外呼不是任务外呼,不用转人工) </div>
72
- <div>- tip:监听任务:接听后只可以听到ai和用户的对话,转人工后才可以和用户直接对话 </div>
73
- <div>7. 挂断</div>
74
- </div>
75
- <div style="float: left;margin-left: 20px">
76
- <div style="margin-bottom: 15px">
77
- 三、具体步骤:
78
- </div>
79
- <button id="nap">设置当前坐席进入小休状态</button>
80
- <br>
81
- <br>
82
- <button id="online">1. 设置当前坐席在线</button>
83
- <br>
84
- <br>
85
- <button id="connectToServer">2. 连接外呼服务器</button>
86
- <br>
87
- <br>
88
- <button id="disconnect" disabled>断开连接服务器</button>
89
- <br>
90
- <br>
91
- <button id="callButton">3. 手动呼叫</button>
92
- : <input id="call" />
93
- <br>
94
- <br>
95
- <button id="ignore" disabled>忽略</button>
96
- <br>
97
- <br>
98
- <button id="answer" disabled>4. 接听</button>
99
- <br>
100
- <br>
101
- <button id="hangUp" disabled>5. 挂断</button>
102
- <br>
103
- <br>
104
- <button id="sendStarDTMF" disabled>按*转人工</button>
105
- <br>
106
- <br>
107
- <button id="localVoiceAccess" disabled>本地声音接入(默认接入)</button>
108
- <br>
109
- <br>
110
- <button id="remoteSoundAccess" disabled>远程声音接入(默认接入)</button>
111
- <br>
112
- <br>
113
- <button id="localSoundDisconnection" disabled>本地声音断开</button>
114
- <br>
115
- <br>
116
- <button id="remoteSoundDisconnection" disabled>远程声音断开</button>
117
- <br>
118
- <br>
119
- <button id="check">权限网络检测</button>
120
- <br>
121
- <br>
122
- <audio
123
- id="remoteAudio"
124
- controls
125
- style="display:none"
126
- >
127
- <p>Your browser doesn't support HTML5 audio - remoteAudio</p>
128
- </audio>
129
- <audio
130
- id="localAudio"
131
- style="display:none"
132
- src="./antique_phone.mp3"
133
- controls
134
- loop
135
- >
136
- <p>Your browser doesn't support HTML5 audio - localAudio</p>
137
- </audio>
138
- </div>
139
- </div>
140
- <div>
141
- 四、当前聊天记录信息:
142
- <pre id="chatInfo">
143
- </pre>
144
- </div>
145
-
146
- <script src="./fp.umd.min.js"></script>
147
- <script src="./CryptoJS.js"></script>
148
- <script src="./softphone.umd.min.js"></script>
149
-
150
- <script>
151
- document.addEventListener('DOMContentLoaded', async (event) => {
152
- const phoneRing = './antique_phone.mp3'
153
-
154
- /**
155
- * 开启电话响铃
156
- */
157
- const phoneRings = () => {
158
- remoteAudio.src = phoneRing
159
- playMedia('localAudio')
160
- }
161
-
162
- /**
163
- * 关闭电话响铃
164
- */
165
- const stopPhoneRings = () => {
166
- remoteAudio.src = ''
167
- pauseMedia('localAudio')
168
- }
169
-
170
- /**
171
- * 获取dom
172
- */
173
- const info = document.getElementById('info')
174
- const ignore = document.getElementById('ignore')
175
- const answer = document.getElementById('answer')
176
- const hangUp = document.getElementById('hangUp')
177
- const connectToServer = document.getElementById('connectToServer')
178
- const call = document.getElementById('call')
179
- const callButton = document.getElementById('callButton')
180
- const nap = document.getElementById('nap')
181
- const chatInfo = document.getElementById('chatInfo')
182
- const online = document.getElementById('online')
183
- const disconnect = document.getElementById('disconnect')
184
- const sendStarDTMF = document.getElementById('sendStarDTMF')
185
- const localVoiceAccess = document.getElementById('localVoiceAccess')
186
- const remoteSoundAccess = document.getElementById('remoteSoundAccess')
187
- const localSoundDisconnection = document.getElementById('localSoundDisconnection')
188
- const remoteSoundDisconnection = document.getElementById('remoteSoundDisconnection')
189
- const check = document.getElementById('check')
190
- const volumn = document.getElementById('volumn')
191
- const browserSoftphoneEnv = document.getElementById('browserSoftphoneEnv')
192
- const localAudio = document.getElementById('localAudio')
193
- const remoteAudio = document.getElementById('remoteAudio')
194
-
195
- const {
196
- UserAgentFactory,
197
- UserAgent,
198
- playMedia,
199
- pauseMedia,
200
- SessionState,
201
- getMedia
202
- } = softphone // 👈 sdk
203
-
204
- const extensionNumber = '1000' // 本地fs 分机账号
205
- const extPassword = '1234' // 本地fs 分机密码
206
- const wsProtocol = 'ws' // 本地fs 地址协议
207
- const wsRegisterAddress = '192.168.59.197:5066' // 本地fs 外呼服务器地址
208
- const sipServerHost = `sip:${extensionNumber}@${wsRegisterAddress}` // fs地址
209
- const wsAddress = `${wsProtocol}://${wsRegisterAddress}` // socket地址
210
-
211
- // const extensionNumber = '2839'
212
- // const extPassword = 'zjh13542240708'
213
- // const wsProtocol = 'ws'
214
- // const wsRegisterAddress = '192.168.31.239:5066'
215
- // const sipServerHost = `sip:${extensionNumber}@${wsRegisterAddress}`
216
- // const wsAddress = `${wsProtocol}://${wsRegisterAddress}`
217
-
218
- const userAgentManager = UserAgentFactory.getUserAgentManager({
219
- authorizationPassword: extPassword, // 分机密码
220
- authorizationUsername: extensionNumber, // 分机账号
221
- uri: UserAgent.makeURI(sipServerHost), // fs地址
222
- transportOptions: {
223
- server: wsAddress // socket地址
224
- },
225
- logLevel: 'error', // 日志等级,默认error
226
- // viaHost, // fp.umd.min.js生成的唯一值,用来配查呼叫问题,可以不传,内部会自动生成
227
- contactName: extensionNumber, // sip协议要求,同分机账号即可,注意类型为string, 不传默认同分机账号
228
- clusterMode: true,
229
- reClusterRegisterTimeout: 1000,
230
- reClusterConnectTimeout: 1000,
231
- sessionDescriptionHandlerFactoryOptions: { // 如果fs开启b2b没模式不需要传,开启p2p模式要传
232
- iceGatheringTimeout: 2000,
233
- peerConnectionConfiguration: {
234
- iceServers: [{ urls: "stun:stun.l.google.com:19302" }], // stun:stun.freeswitch.org
235
- }
236
- },
237
- refreshSpeekVolumn(value) { // 当来电接通时,实时查看坐席说话的音量实际传送到给对方的音量大小
238
- volumn.innerText = value
239
- },
240
- refreshRequirementCheck(value) { // 权限网络检测
241
- browserSoftphoneEnv.innerText = JSON.stringify(value, null, 2)
242
- },
243
- })
244
-
245
- /**
246
- * 签入
247
- */
248
- const connect = async () => {
249
- try {
250
- await userAgentManager.prepareUserAgent(
251
- { // config
252
- refresh(path, value) { // 当软电话状态变化时会实时刷新这个方法
253
- console.log(path, value)
254
- },
255
- registererOptions: { // 设置会话多长时间过期,然后自动重签, 单位秒
256
- expires: 10 * 60
257
- }
258
- },
259
- { // event
260
- onInvite(invitation) { // 当有外呼过来
261
- // const info = userAgentManager.getCallNumberDetail({
262
- // id: Number(userAgentManager.businessAttribute.numberId), // 根据你需要哪通电话来,这里在来电时获取当前来电详情
263
- // taskId: userAgentManager.businessAttribute.taskId, // 如果不是任务外呼不用传
264
- // })
265
- // console.log(info, '========')
266
- setTimeout(() => {
267
- acceptInvite()
268
- }, 0)
269
- console.log(userAgentManager.businessAttribute)
270
- phoneRings() // 播放模拟来电响铃
271
- invitation.stateChange.addListener((state) => { // 一旦接听(执行accept),监听会话的生命周期
272
- switch (state) {
273
- case SessionState.Initial:
274
- break
275
- case SessionState.Establishing:
276
- break
277
- case SessionState.Established: // session建立后就可拿到webrtc的各种基础api,如userAgentManager.getPeerConnection(),如userAgentManager.getSenders()等等
278
- const mediaElement1 = getMedia('remoteAudio')
279
- mediaElement1.srcObject = userAgentManager.getStream() // 获取流
280
- mediaElement1.play() // 把softphone流导入到audio接入用户语音
281
- hangUp.disabled = false
282
- break
283
- case SessionState.Terminating:
284
- case SessionState.Terminated: // 在挂断电话时候会执行
285
- const mediaElement2 = getMedia('remoteAudio') // 获取audio dom
286
- mediaElement2.srcObject = null
287
- mediaElement2.pause() // 释放audio
288
- stopPhoneRings()
289
-
290
- ignore.disabled = true
291
- answer.disabled = true
292
- hangUp.disabled = true
293
- localSoundDisconnection.disabled = true
294
- remoteSoundDisconnection.disabled = true
295
- localVoiceAccess.disabled = true
296
- remoteSoundAccess.disabled = true
297
- break
298
- default:
299
- throw new Error('Unknown session state.')
300
- }
301
- })
302
- ignore.disabled = false
303
- answer.disabled = false
304
- localSoundDisconnection.disabled = false
305
- remoteSoundDisconnection.disabled = false
306
- }
307
- }
308
- ) // 👈 一键签入
309
- } catch (errorInfo) { // 签入容错提示处理
310
- if (errorInfo.message.indexOf('Invalid WebSocket Server URL') > -1
311
- || errorInfo.message.indexOf('Invalid scheme in WebSocket Server URL') > -1) {
312
- alert('签入配置地址不正确,无法连通完成签入')
313
- } else if (errorInfo.message === 'sip register fail with code 503' ||
314
- (errorInfo.message.indexOf('WebSocket closed') > -1 && errorInfo.message.indexOf('code: 1006') > -1)) {
315
- alert('软电话服务器不可用,签入失败')
316
- } else {
317
- alert(errorInfo.message)
318
- }
319
- throw errorInfo
320
- }
321
- disconnect.disabled = false
322
- connectToServer.disabled = true
323
- ignore.disabled = true
324
- answer.disabled = true
325
- hangUp.disabled = true
326
- localSoundDisconnection.disabled = true
327
- remoteSoundDisconnection.disabled = true
328
- localVoiceAccess.disabled = true
329
- remoteSoundAccess.disabled = true
330
- }
331
-
332
- /**
333
- * 签出
334
- */
335
- const disConnect = async () => {
336
- await userAgentManager.dispose() // 👈 一个方法安全销毁,一键签出
337
- connectToServer.disabled = false
338
- disconnect.disabled = true
339
- ignore.disabled = true
340
- answer.disabled = true
341
- hangUp.disabled = true
342
- localSoundDisconnection.disabled = true
343
- remoteSoundDisconnection.disabled = true
344
- localVoiceAccess.disabled = true
345
- remoteSoundAccess.disabled = true
346
- }
347
-
348
- /**
349
- * 按*号转人工,返回promise,可以做loading效果做点击锁
350
- */
351
-
352
- const sendStarDtmf = async () => {
353
- // 由于 【坐席外呼类型】 没有配置要不要转人工的入口
354
- // 而:【坐席快速外呼】 不需要 转人工;【坐席ai外呼】 一定要 转人工;其他外呼类型根据userAgentManager.notNeedSendStarDtmf(true不需要,false需要,即本质是根据配置),如任务类型外呼根据任务的配置
355
- // userAgentManager.getFastOutboundCall判断是否坐席快速外呼(true是false否)
356
- // userAgentManager.getSitOutboundCall判断是否坐席ai外呼(true是false否)
357
- if ((!userAgentManager.notNeedSendStarDtmf() && !userAgentManager.getFastOutboundCall()) || userAgentManager.getSitOutboundCall()) {
358
- await new Promise((resolve, reject) => {
359
- const fn = async () => {
360
- await userAgentManager.sendStarDtmf({
361
- requestDelegate: {
362
- onAccept () { // 👈 转人工响应成功
363
- resolve(true)
364
- },
365
- async onReject (info) { //👈 转人工响应超时或失败
366
- alert('转人工响应失败:' + info.message?.statusCode + ':' + info.message?.reasonPhrase)
367
- reject(new Error(info.message.statusCode + ':' + info.message.reasonPhrase))
368
- }
369
- }
370
- }) // 👈 一键转人工,await的下行代码被执行说明成功发出转人工信令
371
- sendStarDTMF.disabled = true
372
- }
373
- fn()
374
- })
375
- }
376
- }
377
-
378
- /**
379
- * 挂断
380
- */
381
- const hangUpInvite = async () => {
382
- await new Promise((resolve, reject) => {
383
- const fn = async () => {
384
- await userAgentManager.hangUpInvite({
385
- scoutResponse: true, // 标识是手动挂断,手动挂断无需等待响应,信号成功发出立即重置会话状态。
386
- byeOptions: {
387
- requestDelegate: {
388
- onAccept (response) { // 👈 挂断响应成功
389
- resolve(response)
390
- },
391
- onReject: (response) => { // 👈 挂断响应超时或失败
392
- alert('挂断响应失败: ' + response?.message?.statusCode + ': ' + response?.message?.reasonPhrase) // 会话终止
393
- reject(new Error(response?.message?.statusCode + ': ' + response?.message?.reasonPhrase))
394
- }
395
- }
396
- },
397
- }) // 👈 一键挂断, 下行代码执行,说明挂端信令成功发出
398
- stopPhoneRings() // 暂停来电铃声,正常挂断不需要处理铃声(因为已经接听,会话已建立,才能挂断),这里做个兜底
399
- ignore.disabled = true
400
- answer.disabled = true
401
- hangUp.disabled = true
402
- localSoundDisconnection.disabled = true
403
- remoteSoundDisconnection.disabled = true
404
- localVoiceAccess.disabled = true
405
- remoteSoundAccess.disabled = true
406
- }
407
- fn()
408
- })
409
- }
410
- /**
411
- * 忽略
412
- */
413
- const ignoreInvite = async () => {
414
- stopPhoneRings() // 暂停来电铃声
415
- await userAgentManager.ignoreInvite() // 👈 一键忽略,下行代码被执行说明忽略信令成功发出
416
- ignore.disabled = true
417
- answer.disabled = true
418
- hangUp.disabled = true
419
- localSoundDisconnection.disabled = true
420
- remoteSoundDisconnection.disabled = true
421
- localVoiceAccess.disabled = true
422
- remoteSoundAccess.disabled = true
423
- }
424
- /**
425
- * 接听
426
- */
427
- const acceptInvite = async () => {
428
- stopPhoneRings() // 暂停来电铃声
429
- try {
430
- await new Promise((resolve, reject) => {
431
- const fn = async () => {
432
- try {
433
- await userAgentManager.acceptInvite({
434
- onAck (info) { // 👈 接听响应成功
435
- resolve(info)
436
- },
437
- onAckTimeout () { // 👈 接听响应失败
438
- reject(new Error('接听响应失败'))
439
- }
440
- }) // 👈 一键接听,下行代码被执行说明接听信令被成功发出
441
- } catch (e) {
442
- console.log('accept error:', e.message)
443
- reject(e)
444
- throw e
445
- }
446
- console.log('接听信令被成功发出')
447
- }
448
- fn()
449
- })
450
- // 接听信令不能被发出,可能原因如下:
451
- } catch (error) { // 接听容错提示处理
452
- if (error.message === 'Requested device not found'
453
- || error.message === 'The object can not be found here.') { // 设备问题
454
- alert('未检测到耳麦设备,已自动断开来电')
455
- throw error
456
- } else if (error.message === 'The request is not allowed by the user agent or the platform in the current context.'
457
- || error.message === 'Media devices not available in insecure contexts.') { // 设备权限和浏览器api权限问题
458
- if (navigator.userAgent.indexOf('Firefox') > -1) {
459
- alert('软电话功能需要获取麦克风权限,如果没有麦克风权限或者http域名未配置insecure contexts都会引起连接会话立即终止,如果当前浏览器访问的地址是https协议,大部分连接会话终止的原因是没有麦克风权限')
460
- } else {
461
- alert('浏览器webrtc功能默认需要网站域名升级到https,如果当前域名为http,请配置浏览器insecure以指定域名白名单使用webrtc api,此时才可获取设备等权限以使用软电话功能')
462
- }
463
- throw error
464
- } else if (error.message === 'Permission denied') { // 麦克风权限问题
465
- alert('没有麦克风权限,请开启')
466
- throw error
467
- } else if (error.message === 'RTCPeerConnection is not defined') { // 浏览器版本问题
468
- alert('当前浏览器版本过低不支持webrtc,推荐使用新版的谷歌或360或edge浏览器')
469
- throw error
470
- }
471
- throw error
472
- }
473
- // 由于 【坐席外呼类型】 没有配置要不要转人工的入口
474
- // 而:【坐席快速外呼】 不需要 转人工;【坐席ai外呼】 一定要 转人工;其他外呼类型根据userAgentManager.notNeedSendStarDtmf(true不需要,false需要,根据配置),如任务类型外呼根据任务配置
475
- // userAgentManager.getFastOutboundCall判断是否坐席快速外呼(true是false否)
476
- // userAgentManager.getSitOutboundCall判断是否坐席ai外呼(true是false否)
477
- if ((!userAgentManager.notNeedSendStarDtmf() && !userAgentManager.getFastOutboundCall()) || userAgentManager.getSitOutboundCall()) {
478
- sendStarDTMF.disabled = false // 打开页面转人工功能
479
- }
480
- hangUp.disabled = false
481
- answer.disabled = true
482
- ignore.disabled = true
483
- }
484
-
485
- /**
486
- * 本地声音推流通道 -> 默认开
487
- * 手动打开 本地声音推流通道(打开本地声音发送)
488
- */
489
- const unMuteLocalAudio = () => {
490
- localVoiceAccess.disabled = true
491
- localSoundDisconnection.disabled = false
492
- userAgentManager.unMuteLocalAudio() // 👈 一键
493
- }
494
- /**
495
- * 本地声音推流通道 -> 默认开
496
- * 手动关闭 本地声音推流通道(关闭本地声音发送)
497
- */
498
- const muteLocalAudio = () => {
499
- remoteSoundAccess.disabled = true
500
- remoteSoundDisconnection.disabled = false
501
- userAgentManager.muteLocalAudio() // 👈 一键
502
- }
503
- /**
504
- * 远端声音拉流通道 -> 默认开
505
- * 手动打开 远端声音拉流通道(用以打开远端声音接收)
506
- */
507
- const unMuteRemoteAudio = () => {
508
- localSoundDisconnection.disabled = true
509
- localVoiceAccess.disabled = false
510
- userAgentManager.unMuteRemoteAudio() // 👈 一键
511
- }
512
- /**
513
- * 远端声音拉流通道 -> 默认开
514
- * 手动关闭 远端声音拉流通道(用以关闭远端声音接收)
515
- */
516
- const muteRemoteAudio = () => {
517
- remoteSoundDisconnection.disabled = true
518
- remoteSoundAccess.disabled = false
519
- userAgentManager.muteRemoteAudio() // 👈 一键
520
- }
521
-
522
- /**
523
- * 呼叫
524
- */
525
- const callPhone = async () => {
526
- // const callInfo = await userAgentManager.callNumber() // 👈 一键
527
- // if (callInfo.code === 200) { // 正确响应
528
- // alert('呼叫成功')
529
- // } else {
530
- // alert(callInfo.message)
531
- // }
532
- await userAgentManager.invite({
533
- extension: call.value
534
- })
535
- }
536
-
537
- /**
538
- * 切换坐席进入小休
539
- */
540
- const toggleNap = async () => {
541
- const napInfo = await userAgentManager.toggleNap(true) // 👈 一键
542
- if (napInfo.code === 200) { // 正确响应
543
- nap.disabled = true
544
- online.disabled = false
545
- alert('进入小休成功')
546
- } else {
547
- alert(napInfo.message)
548
- }
549
- }
550
-
551
- /**
552
- * 切换坐席进入在线
553
- */
554
- const toggleOnline = async () => {
555
- const napInfo = await userAgentManager.toggleNap(false) // 👈 一键
556
- if (napInfo.code === 200) { // 正确响应
557
- nap.disabled = false
558
- online.disabled = true
559
- alert('设置坐席在线成功')
560
- } else {
561
- alert(napInfo.message)
562
- }
563
- }
564
-
565
- /**
566
- * 环境检测
567
- */
568
- const envCheck = () => {
569
- userAgentManager.softphoneEnvCheck() // 👈 一键检测,检测出结果后会回调在生成软电话实例时注册的钩子 refreshRequirementCheck
570
- }
571
-
572
- /** 各种操作按钮 注册事件开始 */
573
- ignore.addEventListener('click', ignoreInvite) // 忽略
574
- answer.addEventListener('click', acceptInvite) // 接听
575
- hangUp.addEventListener('click', hangUpInvite) // 挂断
576
- connectToServer.addEventListener('click', connect) // 签入
577
- disconnect.addEventListener('click', disConnect) // 签出
578
- sendStarDTMF.addEventListener('click', sendStarDtmf) // 转人工
579
- localVoiceAccess.addEventListener('click', unMuteLocalAudio) // 打开本地声音发送
580
- remoteSoundAccess.addEventListener('click', muteLocalAudio) // 关闭本地声音发送
581
- localSoundDisconnection.addEventListener('click', unMuteRemoteAudio) // 打开远端声音接收
582
- remoteSoundDisconnection.addEventListener('click', muteRemoteAudio) // 关闭远端声音接收
583
- callButton.addEventListener('click', callPhone) // 呼叫
584
- nap.addEventListener('click', toggleNap) // 切换坐席进入小休
585
- online.addEventListener('click', toggleOnline) // 切换坐席进入在线
586
- check.addEventListener('click', envCheck) // 执行软电话必备的权限&网络环境检测
587
- /** 注册事件结束 */
588
- })
589
-
590
-
591
- </script>
592
- </body>
593
- </html>