joinRoom method
- NSString token,
- ByteRTCUserInfo userInfo,
- BOOL userVisibility,
- ByteRTCRoomConfig roomConfig,
@detail api
@author shenpengliang
@brief Join the RTC room.
After creating a room by calling createRTCRoom:{@link #ByteRTCEngine#createRTCRoom}, call this API to join the room and make audio & video calls with other users in the room.
@param token Dynamic key 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 Authentication with Token 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 ByteRTCUserInfo{@link #ByteRTCUserInfo}.
@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 #ByteRTCRoom#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 ByteRTCRoomConfig{@link #ByteRTCRoomConfig} for the specific configuration mode.
@return Method call result.
- 0: Success.
- Local users receive notifications of the room state via rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo}.
- Local users receive notifications of the local-stream state via rtcRoom:onVideoPublishStateChanged:info:state:reason:{@link #ByteRTCRoomDelegate#rtcRoom:onVideoPublishStateChanged:info:state:reason}, rtcRoom:onAudioPublishStateChanged:info:state:reason:{@link #ByteRTCRoomDelegate#rtcRoom:onAudioPublishStateChanged:info:state:reason}.
- Local users receive notifications of the subscribed-stream state via rtcRoom:onVideoSubscribeStateChanged:info:state:reason:{@link #ByteRTCRoomDelegate#rtcRoom:onVideoSubscribeStateChanged:info:state:reason}, rtcRoom:onAudioSubscribeStateChanged:info:state:reason:{@link #ByteRTCRoomDelegate#rtcRoom:onAudioSubscribeStateChanged:info:state:reason}, rtcRoom:onScreenVideoSubscribeStateChanged:userId:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onScreenVideoSubscribeStateChanged:userId:state:reason}, and/or rtcRoom:onScreenAudioSubscribeStateChanged:userId:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onScreenAudioSubscribeStateChanged:userId:state:reason}.
- Local users receive notifications of the published-stream state via rtcRoom:onUserPublishStreamVideo:info:isPublish:{@link #ByteRTCRoomDelegate#rtcRoom:onUserPublishStreamVideo:info:isPublish}, rtcRoom:onUserPublishStreamVideo:info:isPublish:{@link #ByteRTCRoomDelegate#rtcRoom:onUserPublishStreamVideo:info:isPublish}.
- If the local user is also a visible user, the other participants receive rtcRoom:onUserJoined:{@link #ByteRTCRoomDelegate#rtcRoom:onUserJoined} callback.
- -1: Invalid parameter
- -2: Already in the room. After the interface call is successful, as long as the return value of 0 is received and leaveRoom{@link #ByteRTCRoom#leaveRoom} is not called successfully, this return value will be 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 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} callback.
@note
- In the same room with the same AppID, the user ID of each user must be unique. If two users have the same user ID, the user who joined the room later will kick the user who joined the room first out of the room, and the user who joined the room first will receive rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} callback notification, the error type is duplicate login ByteRTCErrorCodeDuplicateLogin.
- Local users will receive rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} callback notification after calling this method to join the room successfully. If the local user is also a visible user, the remote user will receive an rtcRoom:onUserJoined:{@link #ByteRTCRoomDelegate#rtcRoom:onUserJoined} callback notification when joining the room.
- By default, the user is visible in an RTC room. Joining fails when the number of users in an RTC room reaches its upper limit. To avoid this, call setUserVisibility:{@link #ByteRTCRoom#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 time rtcEngine:onConnectionStateChanged:{@link #ByteRTCEngineDelegate#rtcEngine:onConnectionStateChanged} callback will be triggered and the SDK will automatically retry until it successfully reconnects to the server. After successful reconnection, you will receive a callback notification from rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} locally.
Implementation
FutureOr<int> joinRoom(NSString token, ByteRTCUserInfo userInfo,
BOOL userVisibility, ByteRTCRoomConfig roomConfig) async {
return await nativeCall('joinRoom:userInfo:userVisibility:roomConfig:',
[token, userInfo, userVisibility, roomConfig]);
}