Skip to main content

Exit Chatroom

Exiting a chatroom can occur under the following scenarios:

  • Passive Exit from Chatroom: The chatroom has an automatic kick-out mechanism for offline members. When this mechanism is triggered, the RC server will remove the user from the chatroom. If a user is banned, they will also be kicked out of the chatroom.
  • Active Exit from Chatroom: The client provides an API that allows users to actively exit the chatroom.

Automatic Kick-out Mechanism for Offline Chatroom Members

The chatroom has an automatic kick-out mechanism for offline members. When a user goes offline, if the following default conditions are met, the RC server will automatically remove the user from the chatroom:

  • If the 31st message is generated in the chatroom within 30 seconds after the user goes offline, the automatic kick-out is triggered.
  • Or, if a new message is generated in the chatroom after the user has been offline for 30 seconds, the automatic kick-out is triggered.
tip
  • The default conditions require that new messages must be generated in the chatroom; otherwise, the kick-out action cannot be triggered. If no messages are generated in the chatroom, abnormal users cannot be kicked out.
  • If you need to modify the default behavior's dependency on new messages, please submit a ticket to apply for the Real-time Kick-out for Abnormal Chatroom Members service. Once this service is enabled, the server will determine whether a user is in an abnormal state based on SDK behavior (requires Android/iOS IMLib SDK version ≧ 5.1.6, Web IMLib version ≧ 5.3.2), and the abnormal user will be kicked out within 5 minutes at the latest.
  • If you need to protect specific users (i.e., prevent automatic kick-out of designated users, as some application scenarios may require users to remain in the chatroom), you can use the Chatroom User Whitelist feature provided by the Server API.

Active Exit from Chatroom

Client users can actively exit the chatroom.

String chatroomId = "Chatroom ID";

RongChatRoomClient.getInstance().quitChatRoom(chatroomId, new IRongCoreCallback.OperationCallback() {

public void onSuccess() {

}

@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});

ParameterTypeDescription
chatRoomIdStringChatroom ID
callbackOperationCallbackCallback interface