Manage room info
ZEGOCLOUD's In-app Chat (the ZIM SDK) provides the capability of room info queries, such as getting the room member list, querying the number of online members in the room, and more.
You can only implement the following features in the room you created or joined.
Get room member list
After joining a room, to know who are in the current room and get the room member list, call the queryRoomMemberList method with roomID
and config
parameters.
The config
parameter refers to the configurations for querying room members. You will need to configure the parameters of the class ZIMRoomMemberQueryConfig according to the following:
Parameter | Type | Required | Description |
---|---|---|---|
nextFlag | string | Yes | The paging identifier. Set this to null for the first query. If the |
count | int | Yes | The number of room members that can be obtained in a query. Note: To save overhead, we recommend you to obtain less than 100 members at a time. |
ZIMRoomMemberQueryConfig config;
config.count = count;
config.nextFlag = string_flag;
zim_->queryRoomMemberList(string_room_id, config, [=](const std::vector<ZIMUserInfo>& member_list, const std::string& next_flag, zim::ZIMError error_info) {
if (error_info.code != 0)
{
ShowMsg(L"Get room member list failed,roomID: %s", string_room_id);
}
else
{
CString string_user_list;
for (auto& member : member_list)
{
CString string_user;
string_user.Format(L"(%s,%s),", member.userID, member.userName);
string_user_list += string_user;
}
ShowMsg(L"Get room member list successfully,roomID: %s,count: %d, users: %s, next flag: %s", string_room_id, member_list.size(), string_user_list, next_flag);
}
});
Get the number of online room members
To get the number of the online room members, call the queryRoomOnlineMemberCount method with the roomID
.
zim_->queryRoomOnlineMemberCount(string_room_id, [=](unsigned int count, zim::ZIMError error_info) {
if (error_info.code != 0)
{
ShowMsg(L"Query the number of online room members failed,roomID: %s",string_room_id);
}
else
{
ShowMsg(L"Query the number of online room members successfully,roomID: %s", string_room_id);
}
});
A room member automatically gets offline if he calls the logout method to log out from the room.
Get room user extended field information
After a user joins a room, the extended information snapshot of the user before joining the room can be obtained through the ZIMUserInfo.userExtendedData
field. This feature can be used to implement business scenarios such as room user level and VIP user identification.
This interface cannot get the extended field information modified after the user joins the room (for example: the userExtendedData
before entering the room is extended1
, and the extended field information after entering the room is extended2
, the content obtained through this interface is still extended1
).
Related interfaces please refer to: queryRoomMemberList、queryRoomMembers、onRoomMemberJoined、onRoomMemberLeft.
- 2.22.0 version onwards.
- If you need to enable this feature, please contact ZEGOCLOUD Technical Support.