이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

TUIRoomEngine

TUIRoomEngine Introduction

TUIRoomEngine SDK TUIRoomEngine SDK provides general audio and video room management, member management, interactive control, instant messaging, and other features, supporting two typical scenarios: Conference and Live.
Installation:
// Use npm
npm i @tencentcloud/tuiroom-engine-electron --save

// Use pnpm
pnpm i @tencentcloud/tuiroom-engine-electron --save

// Use yarn
yarn add @tencentcloud/tuiroom-engine-electron

TUIRoomEngine API

TUIRoomEngine Static Methods

API
Validation
once
Listening TUIRoomEngine ready event.
Note:
All methods other than TUIRoomEngine.init must be executed after the TUIRoomEngine ready event is received and the TUIRoomEngine.init method is successfully executed.
login
Log in to TUIRoomEngine
logout
Log out of TUIRoomEngine
Set basic information of the current user (user name, user avatar)
Get basic information of the current user (user name, user avatar)
Get device manager
Get audio effect manager
Get media source mixing manager
Get video effect plugin manager

roomEngine Room Management API

API
Validation
Create a room
enterRoom
Enter a room
Destroy a room
exitRoom
Exit a room
Fetch room information
Update room name (Only available to room owners or administrators)
Update room seat mode (Only available to room owners or administrators)
Get members list
Get member detail information

roomEngine Video and Audio API

API
Validation
Set the HTML element where to play local camera video stream
Open local camera
Close local camera
Open local microphone
Close local microphone
Set local video parameters
Set the resolution mode of the local video stream
Set local video encoding parameters
Set local audio parameters
Start pushing the local video stream to the remote end
Stop pushing the local video stream to the remote end
Stop pushing the local audio stream to the remote end
Start pushing the local audio stream to the remote end
Set the HTML element where to play the remote video stream
Start playing the remote user's video stream
Stop playing the remote user's video stream
Stop the remote user's audio stream

roomEngine Member Management API

API
Validation
Cancel a request already sent
Response to remote use request
Change user role
Kick user out of current room
Disable/Enable instant message chat

roomEngine Seat Management API

API
Validation
Get seats information
takeSeat
Take a seat
leaveSeat
Release a seat
Invite someone else to speak (only available to room owner and administrators)
Kick someone off the seat (only available to room owner and administrators)
Lock a seat (only available to room owner and administrators)
Get the list of speaking requests

roomEngine Screen/Window Sharing API

API
Validation
Start screen or window sharing
Stop screen or window sharing
Get the screens and windows to be shared
Select the screen or window to share

roomEngine Event Listening API

API
Validation
on
Add TUIRoomEvents event listener
off
Remove TUIRoomEvents event listener

roomEngine Malicious API

API
Validation
Get TRTCCloud instance
getTIM
Get TIM/Chat instance

API Description

once

Listening TUIRoomEngine 'ready' event
TUIRoomEngine.once('ready', () => {
const roomEngine = new TUIRoomEngine();
await TUIRoomEngine.init({
sdkAppId: 0, // Fill your `sdkAppId`
userId: '', // Fill your `userId`
userSig: '', // Fill your `userSig`
});
await roomEngine.createRoom({
roomId: '12345', // Fill room ID of type string
name: 'Test Room', // Fill room name, default value is `roomId`, maximize length: 30
roomType: TUIRoomType.kLive, // Room type should be `TUIRoomType.kLive`
});
});

login

Log in to TUIRoomEngine. Other API can work only after `login` successfully.
// Log in to TUIRoomEngine
await TUIRoomEngine.login({
sdkAppId: 0, // Fill your `sdkAppId`
userId: '', // Fill your `userId`
userSig: '', // Fill the `userSig` responded from server or generated locally.
});
Parameters:
Parameter
Type
Validation
Default value
Description
sdkAppId
number
Required
-
sdkAppId
On TRTC Cloud Console Click `Application Management` > `Create Application`. After creation, you can get the `sdkappId` from application detail information.
userId
string
Required
-
It is recommended that the user ID be limited to 32 bytes and only contain uppercase and lowercase letters (a-zA-Z), digits (0-9), underscores, and hyphens.
userSig
string
Required
-
userSig
For detail about what and how to generate `userSig`, please refer to the online documentation:UserSig.
tim
TIM
Not required
-
If you want to use more capabilities of the Instant Messaging SDK while connecting to roomEngine, you can pass the created tim instance into TUIRoomEngine. For the creation method of the tim instance, please refer to:TIM.create.
Returns Promise<void>

logout

Log out of TUIRoomEngine。
// Log out of TUIRoomEngine
await TUIRoomEngine.logout();
Returns Promise<void>

setSelfInfo

Set basic information of the current user (user name, user avatar)
// Set basic information of the current user (user name, user avatar)
await TUIRoomEngine.setSelfInfo({
userName: '', // Fill your `userName`
avatarUrl: '', // Fill your avatar URL
});
Parameters:
Parameter
Type
Validation
Default value
Description
userName
string
Required
-
User name
avatarUrl
string
Required
-
User avatar
Returns Promise<void>

getSelfInfo

Get basic information of the current user (user name, user avatar)
// Get basic information of the current user (user name, user avatar)
const loginUserInfo = await TUIRoomEngine.getSelfInfo();
Returns Promise<TUILoginUserInfo> loginUserInfo


getDeviceManager

Get device manager
import TUIRoomEngine, {
TUIDeviceManager
} from '@tencentcloud/tuiroom-engine-electron';

const deviceManager:TUIDeviceManager = TUIRoomEngine.getDeviceManager();
Returns TUIDeviceManager

getAudioEffectManager

Get audio effect manager
import TUIRoomEngine, {
TUIAudioEffectManager
} from '@tencentcloud/tuiroom-engine-electron';

const audioEffectManager: TUIAudioEffectManager = TUIRoomEngine.getAudioEffectManager();

getMediaMixingManager

Get media source mixing manager
import TUIRoomEngine, { TUIMediaMixingManager } from '@tencentcloud/tuiroom-engine-electron';

const mediaMixingManager: TUIMediaMixingManager = TUIRoomEngine.getMediaMixingManager();

getVideoEffectPluginManager

Get video effect plugin manager
import TUIRoomEngine, {
TUIVideoEffectPluginManager
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();

createRoom

When the host creates a room, the user who calls createRoom becomes the owner of the room. When creating a room, you can set the room ID, room name, room type, whether to enable seat control, whether to allow users to join and enable audio and video, send messages, and other features.
const roomEngine = new TUIRoomEngine();
await roomEngine.createRoom({
roomId: '12345', // Fill the `roomId`of string type
roomName: 'Test Room', // Enter your room name. The room name defaults to roomId and can be up to 30 bytes long.
roomType: TUIRoomType.kLive, // The room type must be `TUIRoomType.kLive` for online living
isSeatEnabled: false, // Whether to enable microphone seat control.
isMicrophoneDisableForAllUser: false, // Whether to allow joining users to turn on the microphone.
isCameraDisableForAllUser: false, // Whether to allow joining users to turn on the camera.
isMessageDisableForAllUser: false, // Whether to allow joining users to send instance message.
});
Parameters:
Parameter
Type
Validation
Default value
Description
roomId
string
Required
-
Room ID is limited to 64 bytes in length and only supports the following character sets:
Uppercase and lowercase English letters (a-zA-Z),
number(0-9),
Space ! # $ % & ( ) + - : ; < = . > ? @ [ ] ^ _ { } | ~ ,
roomName
string
Optional
roomId
Room name, default to `roomId`, cannot be empty.
roomType
Optional
TUIRoomType.kConference
Room type
For office collaboration, medical consultation, remote meetings, and educational scenarios, set roomType to TUIRoomType.kConference,
for e-commerce live streaming and voice chat room scenarios, set roomType to TUIRoomType.kLive.
isSeatEnabled
boolean
Optional
false
Whether to enable microphone seat control. Default is `false` to not enable.
seatMode
Optional
TUISeatMode.kFreeToTake
Seat mode(enable when microphone seat controlling is enabled), default value:`TUISeatMode.kFreeToTake`
`TUISeatMode.kFreeToTake`: user can open or close microphone and camera freely without requesting for permission. When `seatMode`is `TUISeatMode.kApplyToTake`
TUISeatMode.kApplyToTake: Audience members need the approval of the room owner or administrator before they can speak.
isMicrophoneDisableForAllUser
boolean
Optional
false
Whether to disable users to control their microphones. Not disabled by default.
isCameraDisableForAllUser
boolean
Optional
false
Whether to disable users to control their cameras. Not disabled by default.
isMessageDisableForAllUser
boolean
Optional
false
Whether to disable users to send instance messages. Not disabled by default.
maxSeatCount
number
Optional
-
Maximum number of seats
When `roomType` is `TUIRoomType.kConference`(education and meeting scenarios), there is no limit on the `maxSeatCount` value.
When `roomType` is `TUIRoomType.kLivingRoom`(living scenarios), the maximum value for `maxSeatCount` is 16.
enableCDNStreaming
boolean
Optional
false
Whether to enable CDN live streaming.
cdnStreamDomain
string
Optional
''
The URL domain to receive living stream.
Returns Promise<void>

enterRoom

Enter a room.
const roomEngine = new TUIRoomEngine();
const roomInfo = await roomEngine.enterRoom({
roomId: '12345',
roomType: TUIRoomType.kLive
});
Parameters:
Parameter
Type
Validation
Default value
Description
roomId
string
Required
-
Room ID
roomType
Optional
TUIRoomType.kConference
Room type
Returns Promise<TUIRoomInfo> roomInfo
Get video effect plugin manager

destroyRoom

Room destroying API. Only the room owner can initiate the destroying. Once dissolved, the room cannot be entered.
const roomEngine = new TUIRoomEngine();
await roomEngine.destroyRoom();
Returns Promise<void>

exitRoom

After invoking enterRoom, users can leave the room by calling exitRoom.
const roomEngine = new TUIRoomEngine();
await roomEngine.exitRoom();
Returns Promise<void>

fetchRoomInfo

Fetch room information
const roomEngine = new TUIRoomEngine();
const roomInfo = roomEngine.fetchRoomInfo();
Returns:Promise<TUIRoomInfo> roomInfo

updateRoomNameByAdmin

Update room name (Only available to room owners or administrators)
const roomEngine = new TUIRoomEngine();
await roomEngine.createRoom({ roomId: '12345' });
await roomEngine.updateRoomNameByAdmin({ roomName: 'New room name' });
Parameters:
Parameter
Type
Validation
Default value
Description
roomName
string
Required
-
Room name that can not be empty string.
Returns Promise<void>

updateRoomSeatModeByAdmin

Update room seat mode (Only available to room owners or administrators)
const roomEngine = new TUIRoomEngine();
await roomEngine.createRoom({ roomId: '12345' });
await roomEngine.updateRoomSeatModeByAdmin({
seatMode: TUISeatMode.kApplyToTake, // Update room seat mode
});
Parameters:
Parameter
Type
Validation
Default value
Description
seatMode
Required
-
Room seat mode

getUserList

Get the current room user list. Note that the maximum number of users that can be pulled at one time by this API is 50.
const roomEngine = new TUIRoomEngine();
const userList = [];
let result;
let nextSequence = 0;
do {
result = await roomEngine.getUserList({ nextSequence });
userList.push(...result.userInfoList);
nextSequence = result.nextSequence;
} while (result.nextSequence !== 0)
Parameters:
Parameter
Type
Validation
Default value
Description
nextSequence
number
Optional
0
Offset. By default, users are pulled starting from offset 0.
Returns:Promise<object> result
result.nextSequence is the offset for the next group user pull. If result.nextSequence is 0, it means the userList has been completely pulled.
result.userInfoList is the userList pulled this time.

getUserInfo

Get a user detail information
const roomEngine = new TUIRoomEngine();
const userList = [];
const userInfo = await roomEngine.getUserInfo({
userId: 'user_12345',
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
Get a user detail information by user ID.
Returns:Promise<TUIUserInfo> userInfo
Reture a user detail information


setLocalVideoView

Set the HTML element where to play local camera video stream
const roomEngine = new TUIRoomEngine();
// HTML div element with id 'preview-camera' to play local camera stream
await roomEngine.setLocalVideoView({
view: 'preview-camera',
});
Parameters:
Parameter
Type
Validation
Default value
Description
view
string
Required
-
`id` value of HTML element attribute
Returns:Promise<void>



openLocalCamera

Open local camera
const roomEngine = new TUIRoomEngine();
await roomEngine.setLocalVideoView({
streamType: TUIVideoStreamType.kCameraStream,
view: 'preview-camera',
});
await roomEngine.openLocalCamera();
Returns:Promise<void>

closeLocalCamera

Close local camera
const roomEngine = new TUIRoomEngine();
await roomEngine.closeLocalCamera();
Returns:Promise<void>

openLocalMicrophone

Open local microphone
const roomEngine = new TUIRoomEngine();
await roomEngine.openLocalMicrophone();
Returns:Promise<void>

closeLocalMicrophone

Close local microphone
const roomEngine = new TUIRoomEngine();
await roomEngine.closeLocalMicrophone();
Returns:Promise<void>

updateVideoQuality

Set the encoding parameters of the local camera video stream. The default is TUIVideoProfile.kVideoQuality_720P.
const roomEngine = new TUIRoomEngine();
await roomEngine.updateVideoQuality({
quality: TUIVideoQuality.kVideoQuality_540p,
});
Parameters:
Parameter
Type
Validation
Default value
Description
quality
Required
-
Clear definition TUIVideoProfile.kVideoQuality_360P
Standard definition TUIVideoProfile.kVideoQuality_540P
High definition TUIVideoProfile.kVideoQuality_720P
Ultra high definition TUIVideoProfile.kVideoQuality_1080P
Returns:Promise<void>

setVideoResolutionMode

Set the resolution mode of the local video stream. The default is TUIResolutionMode.kResolutionMode_Landscape.
const roomEngine = new TUIRoomEngine();
await roomEngine.setVideoResolutionMode({
type: TUIVideoStreamType.kCameraStream,
resolutionMode: TUIResolutionMode.kResolutionMode_Landscape,
});
Parameters:
Parameter
Type
Validation
Default value
Description
streamType
Required
-
Video stream type
resolutionMode
Required
TUIResolutionMode.kResolutionMode_Landscape
Resolution mode
Returns:Promise<void>


updateVideoQualityEx

Set the encoding parameters of the local video stream. The default is TUIVideoProfile.kVideoQuality_720P.
const roomEngine = new TUIRoomEngine();
await roomEngine.updateVideoQualityEx({
streamType: TUIVideoStreamType.kCameraStream,
encoderParams: {
videoResolution: TUIVideoQuality.kVideoQuality_720p,
fps: 15,
bitrate: 2000,
resolutionMode: TUIResolutionMode.kResolutionMode_Landscape,
}
});
Parameters:
Parameter
Type
Validation
Default value
Description
streamType
Required
-
Video stream type
encoderParams
Required
-
Detailed encoding parameters


updateAudioQuality

Set local audio parameters.
Note:
This method needs to be called before calling openLocalMicrophone, otherwise it will not take effect.
const roomEngine = new TUIRoomEngine();
await roomEngine.updateAudioQuality({
quality: TUIAudioQuality.kAudioProfileMusic,
});
Parameters:
Parameter
Type
Validation
Default value
Description
audioProfile
Required
-
TUIAudioQuality.kAudioProfileSpeech: Speech Mode; Sample Rate: 16kHz
TUIAudioQuality.kAudioProfileDefault: Standard mode(Default mode); Sample Rate: 48kHz
TUIAudioQuality.kAudioProfileMusic: Music Mode; Sample Rate: 48kHz
Returns:Promise<void>

startPushLocalVideo

After entering the room, the local video stream will be pushed to the remote end by default. This API is used to push the local video stream to the remote end again after stopping the streaming.
const roomEngine = new TUIRoomEngine();
await roomEngine.startPushLocalVideo();
Returns:Promise<void>

stopPushLocalVideo

Stop pushing the local video stream to the remote end
const roomEngine = new TUIRoomEngine();
await roomEngine.stopPushLocalVideo();
Returns:Promise<void>

muteLocalAudio

Stop pushing the local audio stream to the remote end
const roomEngine = new TUIRoomEngine();
await roomEngine.muteLocalAudio();
Returns:Promise<void>

unmuteLocalAudio

Start pushing the local audio stream to the remote end
const roomEngine = new TUIRoomEngine();
await roomEngine.unmuteLocalAudio();
Returns:Promise<void>

setRemoteVideoView

Set the HTML element where to play the remote video stream
const roomEngine = new TUIRoomEngine();

// Play remote video at HTML element with id attribute 'remote_preview_camera'
await roomEngine.setRemoteVideoView({
userId: 'user_1234',
streamType: TUIVideoStreamType.kCameraStream,
view: 'remote_preview_camera',
});
// Play remote user screen sharing at HTML element with id attribute 'remote_preview_screen'
await roomEngine.setRemoteVideoView({
userId: 'user_1234',
streamType: TUIVideoStreamType.kScreenStream,
view: 'remote_preview_screen',
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
streamType
Required
-
Video stream type
view
string
Required
-
`id` value of HTML element attribute
Returns:Promise<void>

startPlayRemoteVideo

Start playing the remote user's video stream
const roomEngine = new TUIRoomEngine();
await roomEngine.startPlayRemoteVideo({
userId: 'user_1234',
streamType: TUIVideoStreamType.kCameraStream,
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
streamType
Required
-
User video stream type
TUIVideoStreamType.kCameraStream Camera video stream
TUIVideoStreamType.kScreenStream Screen/window sharing video stream
TUIVideoStreamType.kCameraStreamLow Camera video stream of Low definition
Returns:Promise<void>

stopPlayRemoteVideo

Stop playing the remote user's video stream
const roomEngine = new TUIRoomEngine();
await roomEngine.stopPlayRemoteVideo({
userId: 'user_1234',
streamType: TUIVideoStreamType.kCameraStream,
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
streamType
Required
-
User video stream type
TUIVideoStreamType.kCameraStream Camera video stream
TUIVideoStreamType.kScreenStream Screen/window sharing video stream
TUIVideoStreamType.kCameraStreamLow Camera video stream of Low definition
Returns:Promise<void>

muteRemoteAudioStream

Stop the remote user's audio stream
const roomEngine = new TUIRoomEngine();
await roomEngine.muteRemoteAudioStream({
userId: 'user_1234',
isMute: true,
});
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
isMute
boolean
Required
-
Whether to stop subscribing remote user audio

cancelRequest

Cancel a request already sent
const roomEngine = new TUIRoomEngine();
await roomEngine.cancelRequest({
requestId: '', // Request unique ID
});
Parameters:
Parameter
Type
Validation
Default value
Description
requestId
string
Required
-
Request ID
Returns:Promise<string> requestId
This API returns a requestId, which can be used by the user to call the cancelRequest API to cancel the request.


responseRemoteRequest

Response to remote use request
const roomEngine = new TUIRoomEngine();
// Agree with remote user request
await roomEngine.responseRemoteRequest({
requestId: '', // Request ID
agree: true,
});
// Disagree with remote user request
await roomEngine.responseRemoteRequest({
requestId: '', // Request ID
agree: false,
});
Parameters:
Parameter
Type
Validation
Default value
Description
requestId
string
Required
-
Request ID
agree
boolean
Required
-
Whether to agree
Returns:Promise<void>

disableSendingMessageByAdmin

Disable/Enable instant message chat
await roomEngine.disableSendingMessageByAdmin({
userId: 'user_1234',
isDisable: true,
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
isDisable
boolean
Required
-
Whether it is disabled
Returns:Promise<void>

changeUserRole

Change the user's role (only the host can call this API).
const roomEngine = new TUIRoomEngine();

// Transfer the room to user user_1234
await roomEngine.changeUserRole({
userId: 'user_1234',
role: TUIRole.kRoomOwner,
});

// Set user user_1234 as the room administrator
await roomEngine.changeUserRole({
userId: 'user_1234',
userRole: TUIRole.kAdministrator,
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
userRole
TUIRole
Required
-
User role
Room owner TUIRole.kRoomOwner
Room administrator TUIRole.kAdministrator
Regular member TUIRole.kGeneralUser
Returns:Promise<void>

kickRemoteUserOutOfRoom

Kick user out of current room
const roomEngine = new TUIRoomEngine();
await roomEngine.kickRemoteUserOutOfRoom({
userId: 'user_1234',
});
Parameters:
Parameter
Type
Validation
Default value
Description
userId
string
Required
-
User ID
Returns:Promise<void>

getSeatList

Get seats information
const roomEngine = new TUIRoomEngine();
const seatList = await roomEngine.getSeatList();
Returns:Promise<TUISeatInfo[]> seatList
seatList Current room seat list

takeSeat

Users off the microphone seat can call takeSeat to become speakers. Only speakers can publish local audio and video streams.
When roomInfo.roomType is TUIRoomType.kConference and roomInfo.seatMode is TUISeatMode.kApplyToTake, ordinary users calling the takeSeat method need to wait for the host/administrator's approval to become speakers.
When roomInfo.roomType is TUIRoomType.kLivingRoom and roomInfo.seatMode is TUISeatMode.kFreeToTake, ordinary users become speakers successfully after calling the takeSeat method.
The room owner & administrator becomes a speaker after successfully calling takeSeat.
Changes to the user microphone-seat list are notified to all users through TUIRoomEvents.onSeatListChanged.
const roomEngine = new TUIRoomEngine();
// Case 1: room owner/administrator takes microphone seat
// Case 2: When roomInfo.roomType is `TUIRoomType.kConference`
// and roomInfo.seatMode `TUISeatMode.kFreeToTake`, regular user takes microphone seat
await roomEngine.takeSeat({
seatIndex: -1,
timeout: 0,
});
// Case 3: When roomInfo.seatMode is TUISeatMode.kApplyToTake, regular user takes microphone seat
const requestId = await roomEngine.instance?.takeSeat({
seatIndex: -1,
timeout: 0,
requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {
switch (requestCallbackType) {
case TUIRequestCallbackType.kRequestAccepted:
// Request is accepted
break;
case TUIRequestCallbackType.kRequestRejected:
// Request is rejected
break;
case TUIRequestCallbackType.kRequestCancelled:
// Request is cancelled
break;
case TUIRequestCallbackType.kRequestTimeout:
// Request is timeout
break;
case TUIRequestCallbackType.kRequestError:
// Incorrect request
break;
default:
break;
}
},
});
Parameters:
Parameter
Type
Validation
Default value
Description
seatIndex
number
Required
-
Microphone seat index. When seat mode is TUISeatMode.kFreeToTake, the value must be -1.
timeout
number
Required
-
Timeout period. If timeout is set to 0, there is no timeout limitation.
requestCallback
Function
Optional
Empty function
Request callback, used to notify the initiator that the request has been accepted/rejected/canceled/timed out/errored.
Returns:Promise<string> requestId
When roomInfo.seatMode is in TUISeatMode.kApplyToTake mode, ordinary users will receive a requestId when calling this interface, and they can use this requestId to call the cancelRequest interface to cancel their request to speak.


leaveSeat

Release a seat
const roomEngine = new TUIRoomEngine();
await roomEngine.leaveSeat();
Returns:Promise<void>

takeUserOnSeatByAdmin

Invite someone else to speak (only available to room owner and administrators)
const roomEngine = new TUIRoomEngine();
const requestId = roomEngine.takeUserOnSeatByAdmin({
seatIndex: 0,
userId: 'user_1234',
timeout: 0,
requestCallback: ({ requestCallbackType, requestId, userId, code, message }) => {
switch (requestCallbackType) {
case TUIRequestCallbackType.kRequestAccepted:
// Request is accepted
break;
case TUIRequestCallbackType.kRequestRejected:
// Request is rejected
break;
case TUIRequestCallbackType.kRequestCancelled:
// Request is cancelled
break;
case TUIRequestCallbackType.kRequestTimeout:
// Request is timeout
break;
case TUIRequestCallbackType.kRequestError:
// Incorrect request
break;
default:
break;
}
},
});
Parameters:
Parameter
Type
Validation
Default value
Description
seatIndex
number
Required
-
Microphone seat index
userId
string
Required
-
User ID
timeout
number
Required
-
Timeout period. If timeout is set to 0, there is no timeout limitation.
requestCallback
Function
Optional
Empty function
Request callback, used to notify the initiator that the request has been accepted/rejected/canceled/timed out/errored.
Returns:Promise<string> requestId
This API returns a requestId, which users can use to call the cancelRequest API to cancel the request.


kickUserOffSeatByAdmin

Kick someone off the seat (only available to room owner and administrators)
const roomEngine = new TUIRoomEngine();
const requestId = await roomEngine.kickUserOffSeatByAdmin({
seatIndex: 0,
userId: 'user_1234',
});
Parameters:
Parameter
Type
Validation
Default value
Description
seatIndex
number
Required
-
Microphone seat index
userId
string
Required
-
User ID
Returns:Promise<void>

lockSeatByAdmin

Lock a seat (only available to room owner and administrators)
const roomEngine = new TUIRoomEngine();
await roomEngine.lockSeatByAdmin({
seatIndex: 0,
lockParams: {
lockSeat: true,
lockVideo: true,
lockAudio: true,
},
});
Parameters:
Parameter
Type
Validation
Default value
Description
seatIndex
number
Required
-
Microphone seat index
lockParams
Required
-
Lock microphone seat parameter
Returns:Promise<void>

getSeatApplicationList

Get the list of speaking requests
const roomEngine = new TUIRoomEngine();
const applicationList = await roomEngine.getSeatApplicationList();
Returns:Promise<TUIRequest[]>

startScreenSharingElectron

Start screen or window sharing
const roomEngine = new TUIRoomEngine();
// Case 1: Start sharing screen
await roomEngine.startScreenSharingElectron({
targetId: 'targetId'
});

// Case 2: Start sharing screen and preview locally
await roomEngine.startScreenSharingElectron({
targetId: 'targetId',
view: 'screen-preview'
});
Parameters:
Parameter
Type
Validation
Default value
Description
targetId
string
Optional
-
Scree or window ID, which can be obtained from getScreenSharingTarget.
view
string
Optional
-
The HTML element ID for local preview of screen sharing
Returns:Promise<void>

stopScreenSharingElectron

Stop screen or window sharing on Electron。
const roomEngine = new TUIRoomEngine();
await roomEngine.stopScreenSharingElectron();
Returns:Promise<void>

getScreenSharingTarget

Get the screens and windows to be shared
const roomEngine = new TUIRoomEngine();
const screenList = await roomEngine.getScreenSharingTarget();
Returns:Promise<void>

selectScreenSharingTarget

Select the screen or window to share
const roomEngine = new TUIRoomEngine();
await roomEngine.selectScreenSharingTarget({
targetId: 'targetId'
});
Parameters:
Parameter
Type
Validation
Default value
Description
targetId
string
Required
-
Screen or window ID, which can be obtained from getScreenSharingTarget.
Returns:Promise<void>

on

Add event listener
const roomEngine = new TUIRoomEngine();
roomEngine.on(event, func);
Parameters:
Parameter
Type
Validation
Default value
Description
event
Required
-
TUIRoomEngine events
func
Function
Required
-
Event handler function
Returns:void

off

Remove roomEngine event listener
const roomEngine = new TUIRoomEngine();
roomEngine.off(event, func);
Parameters:
Parameter
Type
Validation
Default value
Description
event
Required
-
TUIRoomEngine events
func
Function
Required
-
Event handler function
Returns:void

getTRTCCloud

Get the trtcCloud instance. For detail about trtcCloud, please refer to:TRTCCloud API documents
const roomEngine = new TUIRoomEngine();
const trtcCloud = roomEngine.getTRTCCloud();
Returns:TRTCCloud

getTIM

Get the tim instance. For detail about tim instance, please refer to: IM API documents
const roomEngine = new TUIRoomEngine();
const tim = roomEngine.getTIM();
Returns: TIM