Call trtc.exitRoom() to exit the room and end the audio and video call.
await trtc.exitRoom();
// After the exit is successful, you can call the trtc.destroy method to
// destroy the instance and release related resources in a timely manner
// if you do not need to use the trtc instance later.
// The destroyed trtc instance cannot be used again and a new instance needs to be created.
trtc.destroy();
Handling being kicked out
In addition to actively exiting the room, users may also be kicked out of the room for the following reasons.
1. kick: When two users with the same userId enter the same room, the user who entered first will be kicked out. This is not allowed because it may cause abnormal audio and video calls between the two parties, so you should avoid this happening.
2. banned: A user is kicked out of a TRTC room through the server's RemoveUser | RemoveUserByStrRoomId interface. The user will receive a kicked event, and the reason is banned.
3. room-disband: A TRTC room is dissolved through the server's DismissRoom | DismissRoomByStrRoomId interface. After the room is dissolved, all users in the room will receive a kicked event, and the reason is room-disband.
When a user is kicked, the SDK will throw the KICKED_OUT event.
If you encounter any problems during the implementation process, please feel free to open an issue on GitHub issue, and we will work on it as soon as possible.