joinRoom abstract method
- required String token,
- required UserInfo userInfo,
- required RoomConfig roomConfig,
Joins the room.
In a multi-room scenario, after calling RTCVideo.createRTCRoom, you can call this APi to join the created room and make audio/video calls with other users in the room.
token
: Dynamic key for authentication and verification of users entering the room.
You can use the console to generate a temporary token for testing, but should use the key SDK to generate and issue a token on your server for official launch. See Authentication with Token for token validity and generation method.
Apps with different AppIDs can not communicate with each other. 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 failure of joining room. The reason for the failure will be communicated via the RTCRoomEventHandler.onRoomStateChanged callback.
userInfo
: User information.
roomConfig
: Room configuration, setting the room mode and whether to automatically publish or subscribe to streams.
API call result:
- 0: Success
- -1: Failure, invalid parameter in userInfo.
- -2: Failure. After successfully calling this API, this return value is triggered when RTCRoom.joinRoom is called again, regardless of whether the filled room ID and user ID are duplicated, as long as a return value of 0 is received and RTCRoom.leaveRoom is not called successfully.
- -3: Failure, no existed room.
Notes:
- In the same room with the same AppID, each user ID 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 RTCVideoEventHandler.onError, and the error code is
duplicateLogin
. - Local user will receive RTCRoomEventHandler.onRoomStateChanged after calling this method to join the room successfully. If the local user is also a visible user, the remote user will receive an RTCRoomEventHandler.onUserJoined callback notification when joining the room. For visibility settings, see RTCRoom.setUserVisibility.
- After a user joins a room successfully, the SDK may lose connection to the server in case of poor local network conditions. At this point, RTCVideoEventHandler.onConnectionStateChanged callback will be triggered and the SDK will automatically retry until it successfully reconnects to the server. After a successful reconnection, the local user will receive RTCRoomEventHandler.onRoomStateChanged.
Implementation
Future<int?> joinRoom({
required String token,
required UserInfo userInfo,
required RoomConfig roomConfig,
});