joinRoom method
- required string token,
- required UserInfo userInfo,
- required bool userVisibility,
- required RoomConfig roomConfig,
@detail api
@author shenpengliang
@brief Join the RTC room.
After creating a room by calling createRTCRoom{@link #RTCEngine#createRTCRoom}, call this API to join the room and make audio & video calls with other users in the room.
@param token Dynamic key. It is used for authentication and verification of users entering the room.
You need to bring Token to enter the room. When testing, you can use the console to generate temporary tokens. The official launch requires the use of the key SDK to generate and issue tokens at your server level. See Use Token to complete authentication for token validity and generation method.
Apps with different AppIDs are not interoperable.
Make sure that the AppID used to generate the Token is the same as the AppID used to create the engine, otherwise it will cause the join room to fail.
@param userInfo User information. See UserInfo{@link #UserInfo}.
@param userVisibility User visibility. We recommend setting the user visibility to false when entering the room, and then setting it to true via setUserVisibility{@link #RTCRoom#setUserVisibility} when the user needs to send audio & video streams. Joining fails when the number of users in an RTC room reaches the upper limit. An RTC room can accommodate a maximum of 50 visible users, and 30 media streams can be published simultaneously. For more information, see Capability of Users and Streams.
@param roomConfig Room parameter configuration, set the room mode and whether to automatically publish or subscribe to the flow. See RTCRoomConfig{@link #RTCRoomConfig} for the specific configuration mode.
@return
- 0: Success.
- Local users receive notifications of the room state via onRoomStateChanged{@link #IRTCRoomEventHandler#onRoomStateChanged}.
- Local users receive notifications of the local-stream state via onVideoPublishStateChanged{@link #IRTCRoomEventHandler#onVideoPublishStateChanged}, onAudioPublishStateChanged{@link #IRTCRoomEventHandler#onAudioPublishStateChanged}.
- Local users receive notifications of the subscribed-stream state via onUserPublishStreamVideo{@link #IRTCRoomEventHandler#onUserPublishStreamVideo}, onUserPublishStreamAudio{@link #IRTCRoomEventHandler#onUserPublishStreamAudio}.
- Local users receive notifications of the published-stream state via onUserPublishStreamVideo{@link #IRTCRoomEventHandler#onUserPublishStreamVideo}, onUserPublishStreamAudio{@link #IRTCRoomEventHandler#onUserPublishStreamAudio}.
- Local users receive notifications of the subscribed-stream state via onVideoSubscribeStateChanged{@link #IRTCRoomEventHandler#onVideoSubscribeStateChanged}, onAudioSubscribeStateChanged{@link #IRTCRoomEventHandler#onAudioSubscribeStateChanged}.
- If the local user is also a visible user, the other participants receive onUserJoined{@link #IRTCRoomEventHandler#onUserJoined} callback.
- -1: RoomID/userI nfo.uid contains invalid parameters.
- -2: Already in the room. After the interface call is successful, as long as the return value of 0 is received and leaveRoom{@link #RTSRoom#leaveRoom} is not called successfully, this return value is triggered when the room entry interface is called again, regardless of whether the filled room ID and user ID are duplicated.
The reason for the failure will be communicated via the onRoomStateChanged{@link #IRTCRoomEventHandler#onRoomStateChanged} callback.
@note
- In the same room with the same App ID, the user ID of each user must be unique. If two users have the same user ID, the user who entered the room later will kick the user who entered the room out of the room, and the user who entered the room will receive the onRoomStateChanged{@link #IRTCRoomEventHandler#onRoomStateChanged} callback notification. For the error type. See kErrorCodeDuplicateLogin in ERROR_CODE_DUPLICATE_LOGIN{@link #ErrorCode#ERROR_CODE_DUPLICATE_LOGIN}.
- By default, the user is visible in an RTC room. Joining fails when the number of users in an RTC room reaches the upper limit. To avoid this, call setUserVisibility{@link #RTCRoom#setUserVisibility} to change the visibility of the audience users to false by considering the capacity for the invisible users is much larger than that for visible users. An RTC room can accommodate a maximum of 50 visible users, and 30 media streams can be published simultaneously. For more information, see Capability of Users and Streams.
- After the user successfully joins the room, the SDK may lose connection to the server in case of poor local network conditions. At this point, onConnectionStateChanged{@link #IRTCEngineEventHandler#onConnectionStateChanged} callback will be triggered and the SDK will automatically retry until it successfully reconnects to the server. After successful reconnection, onRoomStateChanged{@link #IRTCRoomEventHandler#onRoomStateChanged} callback notification will be received locally.
Implementation
Future<int?> joinRoom(
{required string token,
required UserInfo userInfo,
required bool userVisibility,
required RoomConfig roomConfig}) async {
$a() => ($instance as $p_a.RTCRoom).joinRoom(
token,
unpackObject<$p_a.UserInfo>(userInfo),
userVisibility,
unpackObject<$p_a.RTCRoomConfig>(roomConfig));
$i() => ($instance as $p_i.ByteRTCRoom).joinRoom(
token,
unpackObject<$p_i.ByteRTCUserInfo>(userInfo),
userVisibility,
unpackObject<$p_i.ByteRTCRoomConfig>(roomConfig));
if (Platform.isAndroid) {
return $a();
} else if (Platform.isIOS) {
return $i();
} else {
throw UnsupportedError(
'Not Support Platform ${Platform.operatingSystem}');
}
}