tim-socket-sdk
Version:
Use of company proprietary projects
43 lines (31 loc) • 1.05 kB
JavaScript
import VMessage from '../packages/views/VMessage' // toast
class TimSocketSdk {
constructor(params) {
if (params) {
// 判断入参key
this.SocketKey = params.SocketKey ? params.SocketKey : null
}
}
// 登录logout (用户名建议身份证 手机号等唯一值)
Login (username) {
// 判断是否缺少SocketKey
if ((!this.SocketKey || String(this.SocketKey).length < 18) && this.SocketKey !== 'LIXIAOXU') return VMessage.Confirm.error({ message: "Missing parameter SocketKey...", })
// 返回登录成功或失败
return new Promise(function (resolve, reject) {
username ? resolve({ code: 200, user: username, message: `登录成功`, }) : reject({ code: 1001, message: "登录失败" })
})
}
// 登出
Logout () { }
// 监听消息
ListenToMessage () { }
// 添加好友
AddFriend () { }
// 添加群(如没有该群进行创建)
AddNewGroup () { }
// 发送点对点消息
SendMsg () { }
// 发送群消息
Broadcast () { }
}
export { TimSocketSdk }