@tencentcloud/tuiroom-engine-js v2.7.2
TUIRoomEngine Web SDK
简介
TUIRoomEngine Web SDK 依托腾讯云 实时音视频 TRTC 和 即时通信 IM 服务,为用户提供房间管理,多人实时音视频互动,屏幕分享,成员管理,即时聊天等功能。
安装
// with npm
npm i @tencentcloud/tuiroom-engine-js --save
// with yarn
yarn add @tencentcloud/tuiroom-engine-js
// with pnpm
pnpm i @tencentcloud/tuiroom-engine-js --save
示例代码
import TUIRoomEngine from '@tencentcloud/tuiroom-engine-js';
let roomEngine = null;
// 错误
function onError(error) {
console.error(error);
}
// 音量变化
function onUserVoiceVolumeChanged(eventInfo) {
console.log(eventInfo.userVolumeList);
}
// 网络质量变化
function onUserNetworkQualityChanged(eventInfo) {
console.log(eventInfo.userNetworkList);
}
// 被踢出房间
function onKickedOutOfRoom(eventInfo) {
console.log(`roomId: ${eventInfo.roomId}, ${eventInfo.message}`);
}
// 用户签名 userSig 过期
function onUserSigExpired() {
console.log('userSig expire');
}
// 被踢下线
function onKickedOffLine(eventInfo) {
console.log(`user offline, reason: ${eventInfo.message}`);
}
// 设备变化:设备切换、设备插拔事件
function onDeviceChange(eventInfo) {
console.log(`deviceChange ${JSON.stringify(eventInfo)}`);
}
async function init() {
TUIRoomEngine.once('ready', () => {
roomEngine = new TUIRoomEngine();
roomEngine.on(TUIRoomEvents.onError, onError);
roomEngine.on(TUIRoomEvents.onUserVoiceVolumeChanged, onUserVoiceVolumeChanged);
roomEngine.on(TUIRoomEvents.onUserNetworkQualityChanged, onUserNetworkQualityChanged);
roomEngine.on(TUIRoomEvents.onKickedOutOfRoom, onKickedOutOfRoom);
roomEngine.on(TUIRoomEvents.onUserSigExpired, onUserSigExpired);
roomEngine.on(TUIRoomEvents.onKickedOffLine, onKickedOffLine);
roomEngine.on(TUIRoomEvents.onDeviceChange, onDeviceChange);
});
// sdkAppId 获取和 userSig 生成详见官网文档
// https://cloud.tencent.com/document/product/647/81962#step1
await TUIRoomEngine.login({ sdkAppId: 0, userId: '', userSig: '' });
await TUIRoomEngine.setSelfInfo({ userName: 'zhangsan', avatarUrl: 'https://testurl' });
}
init();
API 列表
参考文档
7 days ago
11 days ago
22 days ago
1 month ago
2 months ago
2 months ago
3 months ago
5 months ago
6 months ago
2 months ago
4 months ago
5 months ago
5 months ago
4 months ago
2 months ago
2 months ago
2 months ago
5 months ago
5 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago