kang-customer-service

1.0.0 • Public • Published

在线客服系统-服务器端

一个在线客服系统应该包括以下4个端:

  • 服务器端
  • 客户端
  • 客服端
  • 管理平台

服务器端用于提供各平台的通信服务 API。

服务器端

启动服务器

npm start

客户端 API

客户端 API 需要引入 api/customer.js 文件

方法

构造函数 Customer

实例化一个客户端

send(msg, to)

发送消息

  • msg: string 要发送的消息
  • to: string 接收者的ID

request(customer)

事件

事件 参数 说明
onConnected {id: 分配的Socket ID} 连接到服务器
onDisconnect 断开连接
onMessage {from: string 发送者的ID, msg: string 内容} 收到消息
onInputing {id: string 客户ID} 对方正在输入
onResponse {service: string 客服ID} 客服接入

客服端 API

客服端 API 需要引入 api/service.js 文件

方法

构造函数 Service

实例化一个客服端

login(uid, pwd)

登录

  • uid: string 用户名
  • pwd: string 密码

返回:promise 用户信息 {id: string, name: string, sex: number}

response(customer)

响应客户请求 客服端接入客户

  • customer: string 客户ID

getRequests()

获取当前正在等待响应的客户

返回:promise 当前正在等待响应的客户 string[]

事件

事件 参数 说明
onConnected {id: 分配的Socket ID} 连接到服务器
onDisconnect 断开连接
onMessage {from: string 发送者的ID, msg: string 内容} 收到消息
onInputing {id: string 客户ID} 对方正在输入
onRequest {id: string 客户ID} 有新客户接入
onResponse {service: string 客服ID, customer: string 客户ID} 客服已被接入

Package Sidebar

Install

npm i kang-customer-service

Weekly Downloads

4

Version

1.0.0

License

ISC

Unpacked Size

7.28 kB

Total Files

8

Last publish

Collaborators

  • li-kang