joinRoom method

FutureOr<int> joinRoom(
  1. NSString token,
  2. ByteRTCUserInfo userInfo
)

@detail api @author luomingkang @brief Join the game room.
After creating a room by calling createGameRoom:roomConfig:{@link #ByteRTCEngine#createGameRoom:roomConfig}, call this API to join the room and make audio calls with other users in the room. @param token Dynamic key for authenticating the logged-in user.
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 App IDs cannot communicate with each other. - Make sure that the App ID used to generate the Token is the same as the App ID used to create the engine, otherwise it will cause the join room to fail. @param userInfo User information. See ByteRTCUserInfo{@link #ByteRTCUserInfo}. @return - 0: Success. - Local users receive notifications of the room state via rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo}. - If the local user is also a visible user, the other participants receive rtcRoom:onUserJoined:{@link #ByteRTCGameRoomDelegate#rtcRoom:onUserJoined} callback. - -1: Room_id/user_info.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 #ByteRTCGameRoom#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 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} 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 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} callback notification. For the error type. See ByteRTCErrorCodeDuplicateLogin in ByteRTCErrorCode{@link #ByteRTCErrorCode} . - 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, rtcEngine:onConnectionStateChanged:{@link #ByteRTCEngineDelegate#rtcEngine:onConnectionStateChanged} callback will be triggered and the SDK will automatically retry until it successfully reconnects to the server. After a successful reconnection, you will receive a local rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} callback notification.

Implementation

FutureOr<int> joinRoom(NSString token, ByteRTCUserInfo userInfo) async {
  return await nativeCall('joinRoom:userInfo:', [token, userInfo]);
}