@zhaokun/cti 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/index.d.ts +36 -0
- package/latest/index.html +1 -1
- package/latest/zhaokun.cti.min.js +3 -3
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
### 使用
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
import zhaokunCTI from "@zhaokun/cti"
|
|
5
|
+
|
|
6
|
+
content = new zhaokunCTI({
|
|
7
|
+
webrtc: true, // 必填 是否是webrtc
|
|
8
|
+
token: "your_token", // 必填 接口获取的token
|
|
9
|
+
agent: "your_agent", // 必填 坐席工号
|
|
10
|
+
account: "your_account", // 必填 分机号
|
|
11
|
+
socket: "your_socket", // 必填 socket连接地址
|
|
12
|
+
env: "", // debug 打印日志
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
content.onmessage(function (obj) {
|
|
17
|
+
console.log("收到数据", obj)
|
|
18
|
+
const type = obj.type // 消息类型
|
|
19
|
+
const data = obj.data // 消息数据
|
|
20
|
+
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// socket 连接成功
|
|
24
|
+
content.onopen(function (e) {
|
|
25
|
+
console.log("onopen", e)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// 获取在线时间
|
|
30
|
+
content.onlinetime(function (time) {
|
|
31
|
+
// console.log("onlinetime", time)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
content.onpermission(function (permission) {
|
|
35
|
+
// console.log("onpermission", permission)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// socket 连接错误
|
|
39
|
+
content.onerror(function (e) {
|
|
40
|
+
console.log("onerror", e)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// socket 连接断开
|
|
44
|
+
content.onclose(function (e) {
|
|
45
|
+
console.log("onclose", e)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// 错误事件
|
|
49
|
+
content.error(function (e) {
|
|
50
|
+
console.log("error", e)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
content.agent.start()
|
|
54
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface CTIConfig {
|
|
2
|
+
webrtc: boolean;
|
|
3
|
+
token: string;
|
|
4
|
+
agent: string;
|
|
5
|
+
account: string;
|
|
6
|
+
socket: string;
|
|
7
|
+
env?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CTIMessage {
|
|
11
|
+
type: string;
|
|
12
|
+
data: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Agent {
|
|
16
|
+
start(): void;
|
|
17
|
+
call(params: { phone: string; relayNumber?: string }): void;
|
|
18
|
+
answer(): void;
|
|
19
|
+
hangup(): void;
|
|
20
|
+
hold(): void;
|
|
21
|
+
unhold(): void;
|
|
22
|
+
transfer(params: { phone: string }): void;
|
|
23
|
+
mobileAnswer(params: { status: number; relayNumber?: string }): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default class zhaokunCTI {
|
|
27
|
+
constructor(config: CTIConfig);
|
|
28
|
+
agent: Agent;
|
|
29
|
+
onmessage(callback: (message: CTIMessage) => void): void;
|
|
30
|
+
onopen(callback: (event: any) => void): void;
|
|
31
|
+
onerror(callback: (error: any) => void): void;
|
|
32
|
+
onclose(callback: (event: any) => void): void;
|
|
33
|
+
onlinetime(callback: (time: string) => void): void;
|
|
34
|
+
onpermission(callback: (permission: any) => void): void;
|
|
35
|
+
error(callback: (error: any) => void): void;
|
|
36
|
+
}
|
package/latest/index.html
CHANGED