同步专业版server sdk添加获取用户未读数接口

This commit is contained in:
heavyrian2012
2026-06-13 10:13:19 +08:00
parent b2536992b6
commit 457f417a52
5 changed files with 146 additions and 0 deletions
@@ -485,6 +485,15 @@ public class Main {
// 商业版专属功能
if (commercialServer) {
// 获取用户的未读情况
IMResult<OutputUserUnreadCount> userUnreadCountIMResult = UserAdmin.getUserUnreadCount("user1");
if (userUnreadCountIMResult != null && userUnreadCountIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
System.out.println("get user unread count success");
} else {
System.out.println("get user unread count failure");
System.exit(-1);
}
// 获取在线用户总数
IMResult<GetOnlineUserCountResult> getOnlineUserCountResultIMResult = UserAdmin.getOnlineUserCount();
if (getOnlineUserCountResultIMResult != null && getOnlineUserCountResultIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
@@ -414,4 +414,15 @@ public class UserAdmin {
InputUserId inputUserId = new InputUserId(userId);
return AdminHttpUtils.httpJsonPost(APIPath.User_Session_List, inputUserId, GetUserSessionResult.class);
}
/**
* 获取用户的未读数,只有专业版IM服务支持,未读数不是很准确,只能表示一个大概。
* @param userId
* @return 用户的未读数,包括未接收消息和客户端上报的未读数。
* @throws Exception
*/
public static IMResult<OutputUserUnreadCount> getUserUnreadCount(String userId) throws Exception {
InputUserId inputUserId = new InputUserId(userId);
return AdminHttpUtils.httpJsonPost(APIPath.User_Unread_count, inputUserId, OutputUserUnreadCount.class);
}
}