Skip to main content

Leaving a Chatroom

The following scenarios are supported for leaving a chatroom:

  • Passive Exit from Chatroom: Chatrooms have an automatic kick-out mechanism for offline members. When triggered, the RC server will remove users from the chatroom. Users will also be removed if they are banned.
  • Active Exit from Chatroom: The client provides an API that allows users to voluntarily leave the chatroom.

Passive Exit from Chatroom

Chatrooms have an automatic exit mechanism for offline members. When a user goes offline, if the following default preset conditions are met, the RC server will automatically remove the user from the chatroom:

  • If 31 messages are 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 preset 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 removed.
  • To modify the default behavior's dependency on new messages, submit a ticket to apply for the Real-time Kick-out for Abnormal Chatroom Disconnections service. Once 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). Abnormal users can be removed within 5 minutes at the latest.
  • To protect specific users from being automatically kicked out (e.g., in scenarios where users are expected to remain in the chatroom), use the Chatroom User Allowlist feature provided by the Server API.

Active Exit from Chatroom

Client users can voluntarily leave a chatroom.

Parameter Description

ParameterTypeDescription
chatRoomIdStringChatroom ID
callbackOperationCallbackCallback interface

Example Code

String chatroomId = "Chatroom ID";

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

public void onSuccess() {

}

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

}
});