Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
微信小程序 SRTC 音视频 SDK 频道外消息通道使用说明
// im会话id let imSid = ""; let enableIm = async () => { // 调后台api获取启用im token // api.getImToken let token = "后台返回的启用im token"; imSid = await srtc.enableIm(token); }
srtc.onNotifyImEvent = (evt: ImEvent) => { console.log('收到im事件', evt); switch (evt.type) { case ImEventType.IM_MSG: // 收到im消息 // evt.data as ImMsgData break; } }
// 调后台api发送im消息 // api.sendImMsg
// 在onNotifyImEvent里 case ImEventType.RECONNECTING: // 开始重连 break; case ImEventType.RECONNECTED: // 重连成功 break;
// 主动停用 await srtc.disableIm(); // 界面刷新清理 // 被动断开 // 在onNotifyImEvent里 case ImEventType.DISCONNECTED: let data = (evt.data as ImDisconnectEventData); // 可根据reason提示退出原因 alert('im已断开 reason:' + data.reason); // 界面刷新清理 imSid = ""; break;