# 实时消息
# 发送消息
使用Promise (opens new window)Manis.sendTextMessage()
发起开始录制请求,
接收三个参数,
channel
、streamId
和recordType
, 返回一个Promise对象实例
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
msg | string (opens new window) | 需要发送的消息内容 | |
receiver | string (opens new window) | 可选参数, 接收消息的用户ID |
示例:
const msg = 'Hello world'
const receiver = ''
Manis.sendTextMessage(msg, receiver).then(resp => {
console.log('handleMsgResponse: ', resp)
if (resp.code === 200) {
console.log('消息发送成功')
} else {
console.error('消息发送失败, ' + resp.msg)
}
}).catch(e => {
console.error(e)
})
# 收到消息
使用Manis.onTextMessage(callback)
收到会议室内的消息通知,
接收一个回调函数,回调函数中返回事件实体, 根据事件类型做相应逻辑处理.
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
callback | function (opens new window) | 屏幕分享已结束 | 回调函数中返回事件实例 |
示例:
/*订阅有用户进入频道*/
Manis.onTextMessage(msg => {
console.log('收到消息', msg)
})