switchRoom abstract method
- TRTCSwitchRoomConfig config
Switch room
This API is used to quickly switch a user from one room to another.
- If the user's role is
audience
, calling this API is equivalent toexitRoom
(current room) +enterRoom
(new room). - If the user's role is
anchor
, the API will retain the current audio/video publishing status while switching the room; therefore, during the room switch, camera preview and sound capturing will not be interrupted.
This API is suitable for the online education scenario where the supervising teacher can perform fast room switch across multiple rooms.
In this scenario, using switchRoom
can get better smoothness and use less code than exitRoom + enterRoom
.
The API call result will be called back through TRTCCloudListener.onSwitchRoom .
Parameters:
- config (TRTCSwitchRoomConfig): Room parameter.
Note
Due to the requirement for compatibility with legacy versions of the SDK, the
config
parameter contains bothroomId
andstrRoomId
parameters. You should pay special attention as detailed below when specifying these two parameters:
- If you decide to use
strRoomId
, then setroomId
to 0. If both are specified,roomId
will be used.- All rooms need to use either
strRoomId
orroomId
at the same time. They cannot be mixed; otherwise, there will be many unexpected bugs.
Implementation
void switchRoom(TRTCSwitchRoomConfig config);