ue-softphone-sdk-beta 3.0.21 → 3.0.22
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/dist/lib/types/index.d.ts +1 -4
- package/dist/lib/ue-soft-phone.min.js +1 -1
- package/package.json +1 -1
- package/sdkdemo/ue-load.min.js +3 -3
- package/sdkdemo/ue.lib.css +1 -1
- package/sdkdemo/ue.min.js +6 -6
- package/sdkdemo/webphone_ez.html +63 -47
- package/src/index.ts +78 -21
package/sdkdemo/webphone_ez.html
CHANGED
|
@@ -6,55 +6,71 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<!DOCTYPE html>
|
|
8
8
|
<html>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
<script type="text/javascript"></script>
|
|
10
|
+
<!-- <script src="./ue-load.min.js"></script> -->
|
|
11
|
+
<script src="https://softphone-dev.useasy.cn/ue-load.min.js"></script>
|
|
12
|
+
<!-- <script src="https://softphone-dev.useasy.cn/ue-load.min.js"></script> -->
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
<div>
|
|
16
|
+
<div id="button">
|
|
17
|
+
<button id="SHOP_CART_ADD_SKU" onclick="callout();">外呼</button>
|
|
18
|
+
<button id="SHOP_CHECKOUT_CREATE" onclick="hangup();">挂断</button>
|
|
19
|
+
<button id="SHOP_CHECKOUT_CREATE" onclick="loadjs();">动态加js</button>
|
|
20
|
+
<button id="SHOP_CHECKOUT_CREATE" onclick="init();">初始化</button>
|
|
21
21
|
</div>
|
|
22
|
-
</
|
|
22
|
+
</div>
|
|
23
|
+
</body>
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
<script type="text/javascript">
|
|
26
|
+
/* 动态加载js */
|
|
27
|
+
function loadjs () {
|
|
28
|
+
const script = document.createElement('script')
|
|
29
|
+
script.type = 'text/javascript'
|
|
30
|
+
script.src = 'https://softphone.useasy.cn/ue-load.min.js'
|
|
31
|
+
document.body.appendChild(script)
|
|
32
|
+
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log('外部事件接收:', event)
|
|
45
|
-
}
|
|
46
|
-
})
|
|
34
|
+
window.ueSimpleSoftphone.init({
|
|
35
|
+
accountId: 'uecs1',
|
|
36
|
+
agentNumber: '8005',
|
|
37
|
+
password: 'Aa132456@',
|
|
38
|
+
loginType: 'WEBRTC',
|
|
39
|
+
isOpenCallQueue: false,
|
|
40
|
+
isOpenNetwork: true,
|
|
41
|
+
openNlsTranslation: true,
|
|
42
|
+
server: 'https://dev1.useasy.cn/api',
|
|
43
|
+
listenCallEvent: function (event) {
|
|
44
|
+
console.log('外部事件接收:', event)
|
|
47
45
|
}
|
|
46
|
+
})
|
|
47
|
+
/* 初始化 */
|
|
48
|
+
function init () {
|
|
49
|
+
window.ueSimpleSoftphone.init({
|
|
50
|
+
accountId: 'uecs1',
|
|
51
|
+
agentNumber: '8005',
|
|
52
|
+
password: 'Aa132456@',
|
|
53
|
+
loginType: 'WEBRTC',
|
|
54
|
+
isOpenCallQueue: false,
|
|
55
|
+
isOpenNetwork: true,
|
|
56
|
+
openNlsTranslation: true,
|
|
57
|
+
server: 'https://dev1.useasy.cn/api',
|
|
58
|
+
listenCallEvent: function (event) {
|
|
59
|
+
console.log('外部事件接收:', event)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* function callout(){
|
|
65
|
+
ue.call.callout(Object object);
|
|
66
|
+
console.log("外呼");
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
function hangup(){
|
|
71
|
+
ue.call.hangup(Object object)
|
|
72
|
+
console.log("挂断");
|
|
73
|
+
} */
|
|
74
|
+
</script>
|
|
48
75
|
|
|
49
|
-
|
|
50
|
-
ue.call.callout(Object object);
|
|
51
|
-
console.log("外呼");
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
function hangup(){
|
|
56
|
-
ue.call.hangup(Object object)
|
|
57
|
-
console.log("挂断");
|
|
58
|
-
} */
|
|
59
|
-
</script>
|
|
60
|
-
</html>
|
|
76
|
+
</html>
|
package/src/index.ts
CHANGED
|
@@ -802,7 +802,7 @@ export default class ueSoftphone {
|
|
|
802
802
|
timeout: 5000
|
|
803
803
|
};
|
|
804
804
|
this.attachNlsTranslationEventCallbacks.suc = suc;
|
|
805
|
-
ueSoftphone.
|
|
805
|
+
ueSoftphone.createopenNlsTransEventHandle(this.attachNlsTranslationEventCallbacks);
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
},
|
|
@@ -853,11 +853,12 @@ export default class ueSoftphone {
|
|
|
853
853
|
callbacks.SocketOptions = {};
|
|
854
854
|
ueSoftphone.error({ message: "login response error!" });
|
|
855
855
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
856
|
+
if(this.MonitorSocketinstance===null){
|
|
857
|
+
this.MonitorSocketinstance = ueSoftphone.newWebSocket(
|
|
858
|
+
callbacks.server,
|
|
859
|
+
callbacks.SocketOptions
|
|
860
|
+
)
|
|
861
|
+
}
|
|
861
862
|
|
|
862
863
|
this.MonitorSocketinstance.on("connect", () => {
|
|
863
864
|
callbacks.success("connect event serve success!");
|
|
@@ -873,14 +874,6 @@ export default class ueSoftphone {
|
|
|
873
874
|
fn("error");
|
|
874
875
|
}
|
|
875
876
|
});
|
|
876
|
-
// 呼叫对列消息更新
|
|
877
|
-
this.MonitorSocketinstance.on("message", (event, m) => {
|
|
878
|
-
// callbacks.message(event);
|
|
879
|
-
callbacks.message({
|
|
880
|
-
subtype: event.subType,
|
|
881
|
-
data: event.data
|
|
882
|
-
});
|
|
883
|
-
});
|
|
884
877
|
|
|
885
878
|
this.MonitorSocketinstance.on("event", (event, m) => {
|
|
886
879
|
// 互踢逻辑
|
|
@@ -889,7 +882,6 @@ export default class ueSoftphone {
|
|
|
889
882
|
this.MonitorSocketinstance.disconnect();
|
|
890
883
|
try {
|
|
891
884
|
ueSoftphone.webPhone.disconnect();
|
|
892
|
-
console.log(event,"呼叫队列互踢")
|
|
893
885
|
} catch (error) {}
|
|
894
886
|
callbacks.message({
|
|
895
887
|
message: "坐席账户在其他地方登录",
|
|
@@ -901,8 +893,12 @@ export default class ueSoftphone {
|
|
|
901
893
|
});
|
|
902
894
|
|
|
903
895
|
this.MonitorSocketinstance.on("call", (event, m) => {
|
|
904
|
-
|
|
905
|
-
|
|
896
|
+
if(event.subType=='queue'&&ueSoftphone.UserConfig.isOpenCallQueue){
|
|
897
|
+
callbacks.message({
|
|
898
|
+
subtype: event.subType,
|
|
899
|
+
data: event.data
|
|
900
|
+
});
|
|
901
|
+
}
|
|
906
902
|
});
|
|
907
903
|
|
|
908
904
|
// if (callbacks.sdkMonitorType) {
|
|
@@ -918,6 +914,71 @@ export default class ueSoftphone {
|
|
|
918
914
|
// }
|
|
919
915
|
// }
|
|
920
916
|
}
|
|
917
|
+
// 更新转译socket消息推送
|
|
918
|
+
static createopenNlsTransEventHandle(callbacks: any = {}) {
|
|
919
|
+
callbacks.success =
|
|
920
|
+
typeof callbacks.success == "function" ? callbacks.success : ueSoftphone.noop;
|
|
921
|
+
callbacks.error = typeof callbacks.error == "function" ? callbacks.error : ueSoftphone.noop;
|
|
922
|
+
callbacks.message =
|
|
923
|
+
typeof callbacks.message == "function" ? callbacks.message : ueSoftphone.noop;
|
|
924
|
+
callbacks.server =
|
|
925
|
+
callbacks.serve === null || callbacks.serve === undefined
|
|
926
|
+
? "ue-dev1.useasy.cn"
|
|
927
|
+
: callbacks.serve;
|
|
928
|
+
|
|
929
|
+
if (callbacks.SocketOptions === null || callbacks.SocketOptions === undefined) {
|
|
930
|
+
callbacks.SocketOptions = {};
|
|
931
|
+
ueSoftphone.error({ message: "login response error!" });
|
|
932
|
+
}
|
|
933
|
+
if(this.MonitorSocketinstance===null){
|
|
934
|
+
this.MonitorSocketinstance = ueSoftphone.newWebSocket(
|
|
935
|
+
callbacks.server,
|
|
936
|
+
callbacks.SocketOptions
|
|
937
|
+
)
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
this.MonitorSocketinstance.on("connect", () => {
|
|
941
|
+
callbacks.success("转译connect event serve success!");
|
|
942
|
+
callbacks.suc();
|
|
943
|
+
ueSoftphone.log("转译监控connect========");
|
|
944
|
+
});
|
|
945
|
+
this.MonitorSocketinstance.on("error", (error: string, fn: Function) => {
|
|
946
|
+
callbacks.error({
|
|
947
|
+
type: "socketError",
|
|
948
|
+
error: error
|
|
949
|
+
});
|
|
950
|
+
if (fn && typeof fn === "function") {
|
|
951
|
+
fn("error");
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
this.MonitorSocketinstance.on("event", (event, m) => {
|
|
956
|
+
// 互踢逻辑
|
|
957
|
+
if (event.subType === "KICK_OFF") {
|
|
958
|
+
if (event.data.kickoff === true) {
|
|
959
|
+
this.MonitorSocketinstance.disconnect();
|
|
960
|
+
try {
|
|
961
|
+
ueSoftphone.webPhone.disconnect();
|
|
962
|
+
} catch (error) {}
|
|
963
|
+
callbacks.message({
|
|
964
|
+
message: "坐席账户在其他地方登录",
|
|
965
|
+
data: event
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
callbacks.message(event);
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
this.MonitorSocketinstance.on("call", (event, m) => {
|
|
973
|
+
// 转译
|
|
974
|
+
if(event.subType=='translation'&&ueSoftphone.UserConfig.openNlsTranslation){
|
|
975
|
+
callbacks.message({
|
|
976
|
+
subtype: event.subType,
|
|
977
|
+
data: event.data
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
}
|
|
921
982
|
// 对外暴露监听呼叫队列socket方法
|
|
922
983
|
public listenCallQueueEvent = (callbacks: any) => {
|
|
923
984
|
// 若客户对接的demo中无attachMonitorEventCallbacks回调,则无法接收到监控的事件回吐
|
|
@@ -2337,7 +2398,6 @@ class ueWebsocket {
|
|
|
2337
2398
|
this.ws = io.connect(`wss://${server}`, proto);
|
|
2338
2399
|
}
|
|
2339
2400
|
public on(type: string, callback: Function) {
|
|
2340
|
-
console.log(type,'type--->callback',callback)
|
|
2341
2401
|
if (type === "connect") {
|
|
2342
2402
|
this.ws.on(type, callback);
|
|
2343
2403
|
}
|
|
@@ -2355,9 +2415,6 @@ class ueWebsocket {
|
|
|
2355
2415
|
if (type === "event") {
|
|
2356
2416
|
this.ws.on("event", callback);
|
|
2357
2417
|
}
|
|
2358
|
-
if (type === "monitor") {
|
|
2359
|
-
this.ws.on("monitor", callback);
|
|
2360
|
-
}
|
|
2361
2418
|
if (type === "call") {
|
|
2362
2419
|
this.ws.on("call", callback);
|
|
2363
2420
|
}
|