Skip to main content

Binding RTC Rooms

tip

The binding RTC room interface has been supported since client SDK version 5.2.1.

Applicable Scenarios: Chatrooms feature an auto-destruction mechanism. For apps using RC's RTC services that also leverage IMLib SDK's chatroom features for live chat, bullet comments, or attribute recording, consider binding chatrooms to RTC rooms. This ensures chatrooms won't be destroyed prematurely during audio chats or live streams, preventing critical data loss. (This interface is unnecessary when using chatroom features independently.)

After binding an RTC room, when a chatroom meets its auto-destruction conditions, the server first checks whether the bound RTC room (RTCRoomId) still exists:

  • If the bound RTC room exists, the chatroom won't be destroyed.
  • If the bound RTC room has been destroyed, the chatroom will be destroyed immediately.

This interface only establishes a one-way binding relationship from chatroom to RTC room. Therefore, after binding, the active or automatic destruction of an RTC room won't directly trigger the destruction of the chatroom. For details about RTC room destruction mechanisms, see RTC Room Destruction Mechanism.

tip

About Chatroom Auto-Destruction Logic:

Chatrooms feature an auto-destruction mechanism. By default, all chatrooms will automatically remove all members and self-destruct after 1 hour of inactivity (no member joins/leaves or new messages). This duration can be extended or configured for scheduled auto-destruction. See server documentation Chatroom Destruction Mechanism for details.

This interface requires a chatroom ID, so it must be called after successful chatroom creation. The client automatically handles creation and joining when calling the join chatroom interface.

This interface doesn't include user permission controls. It's recommended that only users with room owner or host roles call it once after successfully joining the chatroom; other users don't need to call it.

Interface Description

public abstract void bindChatRoomWithRTCRoom(
String chatRoomId, String rtcRoomId, IRongCoreCallback.OperationCallback callback)

Parameter Description

ParameterTypeDescription
chatRoomIdStringChatroom ID (non-null). The chatroom must already exist. Provided by the app.
rtcRoomIdStringRTC room ID (non-null). Provided by the app.
callbackIRongCoreCallback.OperationCallbackEvent listener callback

Sample Code

String chatRoomId = "Your chatroom ID";
String RTCRoomId = "Your RTC room ID";
RongChatRoomClient.getInstance().bindChatRoomWithRTCRoom(chatRoomId, rtcRoomId, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {

}

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

}
});