enterRoom method
Enter an audio/video call room (hereinafter referred to as "Enter Room").
After calling this API, you will receive the onEnterRoom(result)
callback from TRTCCloudListener :
If room entry succeeded, result
will be a positive number (result
> 0), indicating the time in milliseconds (ms) used for entering the room.
If room entry failed, result
will be a negative number (result
< 0), indicating the error code for room entry failure.
Parameters:
param
Room entry parameters. For more information, please see the definition of the TRTCParams parameter in trtc_cloud_def.dart
scene
Application scenario. Currently, video call (VideoCall), live streaming (Live), audio call (AudioCall), and voice chat room (VoiceChatRoom) are supported.
Note:
-
If
scene
is selected asTRTC_APP_SCENE_LIVE
orTRTC_APP_SCENE_VOICE_CHATROOM
, you must use therole
field inTRTCParams
to specify the role of the current user. -
No matter whether room entry is successful, enterRoom must be used together with exitRoom. If enterRoom is called again before exitRoom is called, an unexpected error will occur.
Implementation
Future<void> enterRoom(TRTCParams param, int scene) {
if (kIsWeb || Platform.isAndroid || Platform.isWindows) {
return _cloudChannel!.invokeMethod('enterRoom', {
"sdkAppId": param.sdkAppId,
"userId": param.userId,
"userSig": param.userSig,
"roomId": param.roomId.toString(),
"strRoomId": param.strRoomId,
"role": param.role,
"streamId": param.streamId,
"userDefineRecordId": param.userDefineRecordId,
"privateMapKey": param.privateMapKey,
"businessInfo": param.businessInfo,
"scene": scene,
});
} else {
return _cloudChannel!.invokeMethod('enterRoom', {
"param": jsonEncode(param),
"scene": scene,
});
}
}