Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
chat-sdk-ws
Advanced tools
Readme
安装:
npm i chat-sdk-ws
调用:
import ChatSDK from 'chat-sdk-ws'
let chat = new ChatSDK()
// 参数说明: url: WebSocket url msgCallback: WebSocket监听消息的回调, openCallback: 连接成功的回调, errCallback: 断开连接的回调, closeCallback: 关闭连接的回调)
chat.initWS(
'wss://xxxxxxxxxx',
(res) => {
console.log(res) // res为WebSocket里onMessage接收到的消息
},
() => {
console.log('连接成功')
},
() => {
console.log('断开连接')
},
() => {
console.log('连接已关闭')
}
)
res 参数说明:
{
current_group_data, // 当前所处群组的成员数据
data, // 所有数据,包括群组列表以及群组内成员数据
dev_group, // 当前所处群组
dev_id, // 当前群组的调度平台
msg_type, // 消息类型
}
// 调用initWS()方法默认调用tryGetPermission()方法
chat.tryGetPermission()
chat.checkPermission()
chat.setAudioMsgRecvCallback((e) => {
console.log(e) // e为语音消息数据
})
chat.getAllDevStatus().then((res) => {
console.log(res) // res为请求成功的返回值
})
// car_plates: 传入数据类型为数组,数组元素为设备的car_plate字段元素 返回一个Promise,需要调.then方法
// 成员邀请要求: 每个成员需要满足: 1.在线(is_online = true) 2.当前设备没有被其他人占用(is_busy = false)
// 调用本方法前,先调用getAllDevStatus()获取所有设备当前状态,传入合要求的car_plate数组
chat.addGroupAndEnter(['豫AXXX', '豫AXXY']).then((res) => {
console.log(res) // res为传入参数之后的返回值
})
// 参数说明:
// callback: 开始录音后的回调
chat.startRecord(() => {
console.log('开始录音')
})
// 参数说明:
// callback: 结束录音后的回调
chat.endRecord((res) => {
console.log(res) // res为结束录音后接收到的数据
})
res 参数说明:
{
msg_type: 'new_audio_data', // 消息格式,当为new_audio_data则说明该数据是一条语音
from_dev: 'WS',
from_dev_name: '我',
arrayBuffer, // 语音buffer格式
time // 语音时长
}
// 参数说明:
// audioMsg: 播放的语音数据(类型: 可传两种类型: ArrayBuffer/base64字符串)
// callback: 播放结束的回调
chat.playAudioMsg(audioMsg, () => {
console.log('播放结束')
})
// 一般通过平台录的音返回的是ArrayBuffer类型, 接收消息返回的是base64字符串,
// 所以播放录音传参数时可以这样写:
chat.playAudioMsg(item.arrayBuffer || item.b64_data, () => {
console.log('播放结束')
})
chat.destroyConnect()
chat.arrayBufferToBase64(buffer)
chat.base64ToArrayBuffer(base64)
FAQs
- npm 方式:
The npm package chat-sdk-ws receives a total of 0 weekly downloads. As such, chat-sdk-ws popularity was classified as not popular.
We found that chat-sdk-ws demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.