# Manage chat room members (/en/realtime-media/im/build/build-groups-rooms-and-threads/chat-room/manage-chatroom-members/unity)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Chat rooms enable real-time messaging among multiple users.

    This page shows how to use the Chat SDK to manage the members of a chat room in your app.

    ## Understand the tech [#understand-the-tech-5]

    The Chat SDK provides the`Room`, `IRoomManager`, and `IRoomManagerDelegate` classes for chat room management, which allow you to implement the following features:

    ## Prerequisites [#prerequisites-5]

    Before proceeding, ensure that you meet the following requirements:

    * You have initialized the Chat SDK. For details, see [SDK quickstart](../../../get-started-sdk).
    * You understand the call frequency limit of the Chat APIs supported by different pricing plans as described in [Limitations](../../limitations).
    * You understand the number of chat rooms supported by different pricing plans as described in [Pricing Plan Details](../../../reference/pricing-plan-details).

    ## Implementation [#implementation-5]

    This section introduces how to call the APIs provided by the Chat SDK to implement the features listed above.

    ### Remove a member from a chat room [#remove-a-member-from-a-chat-room-3]

    Only the chat room owner and admins can call `DeleteRoomMembers` to remove one or more members from a chat room. Once removed from the chat room, this member receives the `OnRemovedFromRoom` callback, while all the other members receive the `OnMemberExitedFromRoom` callback. Users can join the chat room again after being removed.

    The following code sample shows how to remove a member from a chat room:

    ```csharp
    SDKClient.Instance.RoomManager.DeleteRoomMembers(roomId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Retrieve the chat room member list [#retrieve-the-chat-room-member-list-3]

    All chat room members can call `FetchRoomMembers` to retrieve the member list of the current chat room.

    The following code sample shows how to retrieve the chat room member list:

    ```csharp
    // pageSize: The number of chat room members to retrieve per page. The maximum value is 1000.
    // cursor: The starting position for data query. Pass in `null` or an empty string at the first call and the server returns chat room members, starting from the latest one.
    SDKClient.Instance.RoomManager.FetchRoomMembers(roomId, cursor, pageSize, callback: new ValueCallBack>(
      // `members` is of the CursorResult type
      onSuccess: (members) => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Manage the chat room blocklist [#manage-the-chat-room-blocklist-4]

    #### Add a member to the chat room blocklist [#add-a-member-to-the-chat-room-blocklist-3]

    Only the chat room owner and admins can call `BlockRoomMembers` to add the specified member to the chat room blocklist. Once added to the blocklist, this member receives the `OnRemovedFromRoom` callback, while all the other members receive the `OnMemberExitedFromRoom` callback. After being added to blocklist, this user cannot send or receive messages in the chat room. They can no longer join the chat room again until they are removed from the blocklist.

    The following code sample shows how to add a member to the chat room blocklist:

    ```csharp
    SDKClient.Instance.RoomManager.BlockRoomMembers(roomId, members, new CallBack(
      onSuccess: () =>
      {
      },
      onError: (code, desc) =>
      {
      }
    ));
    ```

    #### Remove a member from the chat room blocklist [#remove-a-member-from-the-chat-room-blocklist-3]

    Only the chat room owner and admins can call `UnBlockRoomMembers` to remove the specified member from the chat room blocklist.

    The following code sample shows how to remove a member from the chat room blocklist:

    ```csharp
    SDKClient.Instance.RoomManager.UnBlockRoomMembers(roomId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Retrieve the chat room blocklist [#retrieve-the-chat-room-blocklist-3]

    Only the chat room owner and admins can call `FetchRoomBlockList` to retrieve the chat room blocklist.

    The following code sample shows how to retrieve the chat room blocklist:

    ```csharp
    SDKClient.Instance.RoomManager.FetchRoomBlockList(roomId, pageNum, pageSize, callback: new ValueCallBack>(
      // `list` is of List type
      onSuccess: (list) => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Manage the chat room allow list [#manage-the-chat-room-allow-list-5]

    The chat room owner and admins are added to the chat room allow list by default.

    Messages sent by members in the chat room allow list are of high priority and will be delivered first, but there is no guarantee that they will be successfully delivered. When the load is high, the server discards low-priority messages first. If the load is high even then, the server also discards high-priority messages.

    #### Add a member to the chat room allow list [#add-a-member-to-the-chat-room-allow-list-3]

    Only the chat room owner and admins can call `AddAllowListMembers` to add the specified member to the chat room allow list. Members in the chat room allow list can send chat room messages even when the chat room owner or admin has muted all chat room members. However, if a member is already in the chat room mute list, this member still cannot send messages in the chat room even after being added to the chat room allow list. Once added to the allow list, this member and all the other chat room admins or owner receive the `IRoomManagerDelegate#OnAddAllowListMembersFromChatroom` callback.

    The following code sample shows how to add a member to the chat room allow list:

    ```csharp
    SDKClient.Instance.RoomManager.AddAllowListMembers(roomId, list, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Remove a member from the chat room allow list [#remove-a-member-from-the-chat-room-allow-list-3]

    Only the chat room owner and admins can call `RemoveAllowListMembers` to remove the specified member from the chat room allow list. Once removed from the chat room allow list, this member and all the other chat room admins or owner receive the `IRoomManagerDelegate#OnRemoveAllowListMembersFromChatroom` callback.

    The following code sample shows how to remove a member from the chat room allow list:

    ```csharp
    SDKClient.Instance.RoomManager.RemoveAllowListMembers(roomId, list, new CallBack(
       onSuccess: () => {
       },
       onError: (code, desc) => {
       }
    ));
    ```

    #### Check whether a user is added to the allow list [#check-whether-a-user-is-added-to-the-allow-list-2]

    All chat room members can call `CheckIfInRoomAllowList` to check whether they are added to the chat room allow list.

    The following code sample shows how to check whether a user is on the chat room allow list:

    ```csharp
    SDKClient.Instance.RoomManager.CheckIfInRoomAllowList(roomId, new ValueCallBack(
      onSuccess: (b) => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Manage the chat room mute list [#manage-the-chat-room-mute-list-5]

    #### Add a member to the chat room mute list [#add-a-member-to-the-chat-room-mute-list-3]

    Only the chat room owner and admins can call `MuteRoomMembers` to add the specified member to the chat room mute list. Once added to the mute list, this member and all the other chat room admins or owner receive the `OnMuteListAddedFromRoom` callback.

    **Note**: The chat room owner can mute chat room admins and regular members, whereas chat room admins can only mute regular members.

    The following code sample shows how to add a member to the chat room mute list:

    ```csharp
    // muteMilliseconds: The mute duration. If you pass `-1`, members are muted permanently.
    SDKClient.Instance.RoomManager.MuteRoomMembers(roomId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Remove a member from the chat room mute list [#remove-a-member-from-the-chat-room-mute-list-3]

    Only the chat room owner and admins can call `UnMuteRoomMembers` to remove the specified member from the chat room mute list. Once removed from the mute list, this member and all the other chat room admins or owner receive the `OnMuteListRemovedFromRoom` callback.

    **Note**: The chat room owner can unmute chat room admins and regular members, whereas chat room admins can only unmute regular members.

    The following code sample shows how to remove a member from the chat room mute list:

    ```csharp
    SDKClient.Instance.RoomManager.UnMuteRoomMembers(roomId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Retrieve the chat room mute dictionary [#retrieve-the-chat-room-mute-dictionary]

    Only the chat room owner and admins can call `FetchRoomMuteList` to retrieve the chat room mute dictionary.

    The following code sample shows how to retrieve the chat room mute dictionary:

    ```csharp
    SDKClient.Instance.RoomManager.FetchRoomMuteList(roomId, pageSize, pageNum, callback: new ValueCallBack>(
      onSuccess: (dict) => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Mute and unmute all the chat room members [#mute-and-unmute-all-the-chat-room-members-4]

    #### Mute all the chat room members [#mute-all-the-chat-room-members-3]

    Only the chat room owner and admins can call `MuteRoomMembers` to mute all the chat room members. Once all the members are muted, the `IRoomManagerDelegate#OnAllMemberMuteChangedFromChatroom` callback is triggered and only those in the chat room allow list can send messages in the chat room.

    Unlike muting a chat room member, this kind of mute does not expire automatically after a certain period and you need to call the `UnMuteAllRoomMembers` method to unmute all members in the chat room.

    The following sample code shows how to mute all the chat room members:

    ```csharp
    SDKClient.Instance.RoomManager.MuteRoomMembers(roomId, members, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Unmute all the chat room members [#unmute-all-the-chat-room-members-3]

    Only the chat room owner and admins can call `UnMuteAllRoomMembers` to unmute all the chat room members. All members in the chat room can receive the `IRoomManagerDelegate#OnAllMemberMuteChangedFromChatroom` event and only those in the chat room allow list can send messages in the chat room.

    The following sample code shows how to unmute all the chat room members:

    ```csharp
    SDKClient.Instance.RoomManager.UnMuteAllRoomMembers(roomId, new ValueCallBack(
      onSuccess: (room) => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Manage the chat room owner and admins [#manage-the-chat-room-owner-and-admins-3]

    #### Transfer the chat room ownership [#transfer-the-chat-room-ownership-3]

    Only the chat room owner can call `ChangeRoomOwner` to transfer the ownership to the specified chat room member. Once the ownership is transferred, the former chat room owner becomes a regular member. The new chat room owner and the chat room admins receive the `OnOwnerChangedFromRoom` callback.

    The following code sample shows how to transfer the chat room ownership:

    ```csharp
    SDKClient.Instance.RoomManager.ChangeRoomOwner(roomId, newOwner, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Add a chat room admin [#add-a-chat-room-admin-3]

    Only the chat room owner can call `AddRoomAdmin` to add an admin. Once promoted to an admin, the new admin and the other chat room admins receive the `OnAdminAddedFromRoom` callback.

    The following code sample shows how to add a chat room admin:

    ```csharp
    SDKClient.Instance.RoomManager.AddRoomAdmin(roomId, adminId, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    #### Remove a chat room admin [#remove-a-chat-room-admin-3]

    Only the chat room owner can call `RemoveRoomAdmin` to remove an admin. Once demoted to a regular member, the former admin and the other chat room admins receive the `OnAdminRemovedFromRoom` callback.

    The following code sample shows how to remove a chat room admin:

    ```csharp
    SDKClient.Instance.RoomManager.RemoveRoomAdmin(roomId, adminId, new CallBack(
      onSuccess: () => {
      },
      onError: (code, desc) => {
      }
    ));
    ```

    ### Listen for chat Room Events [#listen-for-chat-room-events-5]

    For details, see [Chat Room Events](manage-chatrooms#listen-for-chat-room-events).

    
  
      
  
