switchRoom abstract method

void switchRoom(
  1. 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 to exitRoom (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:

Note

Due to the requirement for compatibility with legacy versions of the SDK, the config parameter contains both roomId and strRoomId parameters. You should pay special attention as detailed below when specifying these two parameters:

  1. If you decide to use strRoomId, then set roomId to 0. If both are specified, roomId will be used.
  2. All rooms need to use either strRoomId or roomId at the same time. They cannot be mixed; otherwise, there will be many unexpected bugs.

Implementation

void switchRoom(TRTCSwitchRoomConfig config);