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.