类 GroupApi
- java.lang.Object
-
- com.easemob.im.server.api.group.GroupApi
-
public class GroupApi extends java.lang.Object
群API。
-
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<java.lang.Void>
addGroupAdmin(java.lang.String groupId, java.lang.String username)
升级群成员为群管理员。reactor.core.publisher.Mono<java.lang.Void>
addGroupMember(java.lang.String groupId, java.lang.String username)
添加群成员(单个)。reactor.core.publisher.Mono<java.lang.Void>
addGroupMembers(java.lang.String groupId, java.util.List<java.lang.String> usernames)
添加群成员(多个)。reactor.core.publisher.Mono<java.lang.Void>
assignGroup(java.lang.String groupId, java.lang.String newOwner)
转让群组。reactor.core.publisher.Mono<java.lang.String>
createPrivateGroup(java.lang.String groupId, java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, java.lang.String custom, boolean needVerify)
指定群组ID,创建私有群。reactor.core.publisher.Mono<java.lang.String>
createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite)
创建私有群。reactor.core.publisher.Mono<java.lang.String>
createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, java.lang.String custom)
创建私有群。reactor.core.publisher.Mono<java.lang.String>
createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, java.lang.String custom, boolean needVerify)
创建私有群。reactor.core.publisher.Mono<java.lang.String>
createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, java.lang.String custom)
创建私有群。reactor.core.publisher.Mono<java.lang.String>
createPublicGroup(java.lang.String groupId, java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin, java.lang.String custom, boolean needVerify)
指定群组ID,创建公开群。reactor.core.publisher.Mono<java.lang.String>
createPublicGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin)
创建公开群。reactor.core.publisher.Mono<java.lang.String>
createPublicGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin, java.lang.String custom)
创建公开群。reactor.core.publisher.Mono<java.lang.String>
createPublicGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin, java.lang.String custom, boolean needVerify)
创建公开群。reactor.core.publisher.Mono<java.lang.Void>
destroyGroup(java.lang.String groupId)
注销群。reactor.core.publisher.Mono<EMGroup>
getGroup(java.lang.String groupId)
获取群详情。reactor.core.publisher.Mono<java.lang.String>
getGroupAnnouncement(java.lang.String groupId)
获取群公告。reactor.core.publisher.Mono<java.util.List<EMGroup>>
getGroupList(java.util.List<java.lang.String> groupIdList)
获取多个群详情。reactor.core.publisher.Flux<java.lang.String>
listAllGroupMembers(java.lang.String groupId)
获取群全部成员,不包括群组的 Owner。reactor.core.publisher.Flux<java.lang.String>
listAllGroupMembers(java.lang.String groupId, java.lang.String sort)
获取群全部成员,不包括群组的 Owner。reactor.core.publisher.Flux<java.util.Map<java.lang.String,java.lang.String>>
listAllGroupMembersIncludeOwner(java.lang.String groupId, java.lang.String sort)
获取群全部成员,包括群组的 Owner。reactor.core.publisher.Flux<java.lang.String>
listAllGroups()
获取全部群列表。reactor.core.publisher.Flux<GroupResource>
listAllGroupsWithInfo()
获取全部群列表,返回值携带群组信息。reactor.core.publisher.Flux<java.lang.String>
listGroupAdmins(java.lang.String groupId)
获取群全部管理员。reactor.core.publisher.Mono<EMPage<java.lang.String>>
listGroupMembers(java.lang.String groupId, int limit, java.lang.String cursor)
分页获取群成员。reactor.core.publisher.Mono<EMPage<java.lang.String>>
listGroupMembers(java.lang.String groupId, int limit, java.lang.String cursor, java.lang.String sort)
分页获取群成员。reactor.core.publisher.Mono<java.util.List<java.util.Map<java.lang.String,java.lang.String>>>
listGroupMembersIncludeOwner(java.lang.String groupId, int pageNum, int pageSize, java.lang.String sort)
分页获取群组成员列表,包括群组的 Owner。reactor.core.publisher.Mono<EMPage<java.lang.String>>
listGroups(int limit, java.lang.String cursor)
分页获取群列表。reactor.core.publisher.Flux<java.lang.String>
listGroupsUserJoined(java.lang.String username)
获取用户加入的所有群组。reactor.core.publisher.Flux<JoinGroupResource>
listGroupsUserJoinedWithInfo(java.lang.String username)
获取用户加入的所有群组,返回值携带群组信息。reactor.core.publisher.Mono<java.util.List<JoinGroupResource>>
listGroupsUserJoinedWithInfo(java.lang.String username, int pageNum, int pageSize)
分页获取用户加入的所有群组,返回值携带群组信息。reactor.core.publisher.Mono<EMPage<GroupResource>>
listGroupsWithInfo(int limit, java.lang.String cursor)
分页获取群列表,返回值携带群组信息。reactor.core.publisher.Mono<java.lang.Void>
removeGroupAdmin(java.lang.String groupId, java.lang.String username)
降级群管理员为群成员。reactor.core.publisher.Mono<java.lang.Void>
removeGroupMember(java.lang.String groupId, java.lang.String username)
移除群成员。reactor.core.publisher.Mono<java.util.List<EMRemoveMember>>
removeGroupMembers(java.lang.String groupId, java.util.List<java.lang.String> usernames)
移除群成员(多个)。reactor.core.publisher.Mono<java.lang.Void>
updateGroup(java.lang.String groupId, java.util.function.Consumer<UpdateGroupRequest> customizer)
修改群详情。reactor.core.publisher.Mono<java.lang.Void>
updateGroupAnnouncement(java.lang.String groupId, java.lang.String announcement)
更新群公告。reactor.core.publisher.Mono<java.lang.Void>
updateGroupOwner(java.lang.String groupId, java.lang.String username)
修改群主。
-
-
-
构造器详细资料
-
GroupApi
public GroupApi(Context context)
-
-
方法详细资料
-
createPublicGroup
public reactor.core.publisher.Mono<java.lang.String> createPublicGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin)
创建公开群。需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置:
API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().createPublicGroup("owner", "groupName", "description", members, 200, true).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数needApproveToJoin
- 新成员加入需要管理员审批- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPublicGroup
public reactor.core.publisher.Mono<java.lang.String> createPublicGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin, java.lang.String custom)
创建公开群。需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置:
API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().createPublicGroup("owner", "groupName", "description", members, 200, true, "custom").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
EMService service; try { // 修改群组API,允许成员邀请其他用户加入 service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数needApproveToJoin
- 新成员加入需要管理员审批custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPublicGroup
public reactor.core.publisher.Mono<java.lang.String> createPublicGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin, java.lang.String custom, boolean needVerify)
创建公开群。需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置:
API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().createPublicGroup("owner", "groupName", "description", members, 200, true, "custom", true).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
EMService service; try { // 修改群组API,允许成员邀请其他用户加入 service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数needApproveToJoin
- 新成员加入需要管理员审批custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符needVerify
- 是否审核群名称(付费功能,需联系商务开通)- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPublicGroup
public reactor.core.publisher.Mono<java.lang.String> createPublicGroup(java.lang.String groupId, java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean needApproveToJoin, java.lang.String custom, boolean needVerify)
指定群组ID,创建公开群。 需要联系商务开通此功能才可以使用。需要注意的是,目前公开群不允许成员邀请其他用户加入。如果要允许,可以用修改群API设置:
API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().createPublicGroup("groupId", "owner", "groupName", "description", members, 200, true, "custom", true).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
EMService service; try { // 修改群组API,允许成员邀请其他用户加入 service.group().updateSetting("group-id", settings -> settings.memberCanInvite(true)).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群组idowner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数needApproveToJoin
- 新成员加入需要管理员审批custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符needVerify
- 是否审核群名称(付费功能,需联系商务开通)- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPrivateGroup
public reactor.core.publisher.Mono<java.lang.String> createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite)
创建私有群。API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数canMemberInvite
- 普通群成员是否允许邀请新用户入群- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPrivateGroup
public reactor.core.publisher.Mono<java.lang.String> createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, java.lang.String custom)
创建私有群。API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true, "custom").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数canMemberInvite
- 普通群成员是否允许邀请新用户入群custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPrivateGroup
public reactor.core.publisher.Mono<java.lang.String> createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, java.lang.String custom)
创建私有群。API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true, true, true, "custom").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数canMemberInvite
- 普通群成员是否允许邀请新用户入群needInviteConfirm
- 邀请加群,受邀用户是否需要确认needApproveToJoin
- 新成员加入是否需要管理员审批custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPrivateGroup
public reactor.core.publisher.Mono<java.lang.String> createPrivateGroup(java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, java.lang.String custom, boolean needVerify)
创建私有群。API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().privateGroup("owner", "groupName", "description", members, 200, true, true, true, "custom", true).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
owner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数canMemberInvite
- 普通群成员是否允许邀请新用户入群needInviteConfirm
- 邀请加群,受邀用户是否需要确认needApproveToJoin
- 新成员加入是否需要管理员审批custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符needVerify
- 是否审核群名称(付费功能,需联系商务开通)- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
createPrivateGroup
public reactor.core.publisher.Mono<java.lang.String> createPrivateGroup(java.lang.String groupId, java.lang.String owner, java.lang.String groupName, java.lang.String description, java.util.List<java.lang.String> members, int maxMembers, boolean canMemberInvite, boolean needApproveToJoin, boolean needInviteConfirm, java.lang.String custom, boolean needVerify)
指定群组ID,创建私有群。 需要联系商务开通此功能才可以使用。API使用示例:
EMService service; List<String> members = new ArrayList<>(); members.add("userA"); try { String groupId = service.group().privateGroup("groupId", "owner", "groupName", "description", members, 200, true, true, true, "custom", true).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群组IDowner
- 群主的用户名groupName
- 群名,最大长度为 128 字符description
- 群介绍,最大长度为 512 字符members
- 初始群成员的用户名列表maxMembers
- 群最大成员数canMemberInvite
- 普通群成员是否允许邀请新用户入群needInviteConfirm
- 邀请加群,受邀用户是否需要确认needApproveToJoin
- 新成员加入是否需要管理员审批custom
- 群组扩展信息,例如可以给群组添加业务相关的标记,最大长度为 1024 字符needVerify
- 是否审核群名称(付费功能,需联系商务开通)- 返回:
- 群id或错误
- 另请参阅:
- 创建群
-
destroyGroup
public reactor.core.publisher.Mono<java.lang.Void> destroyGroup(java.lang.String groupId)
注销群。请谨慎使用。
API使用示例:
EMService service; try { String groupId = service.group().destroyGroup("groupId").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群id- 返回:
- 成功或错误
-
listAllGroups
public reactor.core.publisher.Flux<java.lang.String> listAllGroups()
获取全部群列表。API使用示例:
EMService service; try { List<String> groups = service.group().listAllGroups().collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 返回:
- 每个群id或错误
- 另请参阅:
- 获取群列表
-
listAllGroupsWithInfo
public reactor.core.publisher.Flux<GroupResource> listAllGroupsWithInfo()
获取全部群列表,返回值携带群组信息。API使用示例:
EMService service; try { List<GroupResource> groups = service.group().listAllGroupsWithInfo().collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 返回:
- 每个群组或错误
- 另请参阅:
- 获取群列表
-
listGroups
public reactor.core.publisher.Mono<EMPage<java.lang.String>> listGroups(int limit, java.lang.String cursor)
分页获取群列表。初次调用时,
cursor
传null
。之后的调用,cursor
传上次返回的值。API使用示例:
EMPage<String> page = null; try { page = service.group().listGroups(10, null).block(); List<String> groupIds = page.getValues(); System.out.println("群组列表:" + groupIds); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } // ... do something with the groupIds ... if (page != null) { String cursor = page.getCursor(); // cursor == null indicates the end of the list while (cursor != null) { try { page = service.group().listGroups(10, cursor).block(); System.out.println("群组列表:" + page.getValues()); // ... do something to the groupIds ... cursor = page.getCursor(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } } }
-
listGroupsWithInfo
public reactor.core.publisher.Mono<EMPage<GroupResource>> listGroupsWithInfo(int limit, java.lang.String cursor)
分页获取群列表,返回值携带群组信息。初次调用时,
cursor
传null
。之后的调用,cursor
传上次返回的值。API使用示例:
EMPage<GroupResource> page = null; try { page = service.group().listGroupsWithInfo(10, null).block(); List<GroupResource> groupIds = page.getValues(); System.out.println("群组列表:" + groupIds); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } // ... do something with the groupIds ... if (page != null) { String cursor = page.getCursor(); // cursor == null indicates the end of the list while (cursor != null) { try { page = service.group().listGroupsWithInfo(10, cursor).block(); System.out.println("群组列表:" + page.getValues()); // ... do something to the groupIds ... cursor = page.getCursor(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } } }
-
listGroupsUserJoined
public reactor.core.publisher.Flux<java.lang.String> listGroupsUserJoined(java.lang.String username)
获取用户加入的所有群组。API使用示例:
EMService service; try { List<String> groups = service.group().listGroupsUserJoined("username").collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
username
- the username- 返回:
- A
Flux
which emitsEMGroup
on successful.
-
listGroupsUserJoinedWithInfo
public reactor.core.publisher.Flux<JoinGroupResource> listGroupsUserJoinedWithInfo(java.lang.String username)
获取用户加入的所有群组,返回值携带群组信息。API使用示例:
EMService service; try { List<JoinGroupResource> groups = service.group().listGroupsUserJoined("username").collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
username
- the username- 返回:
- A
Flux
which emitsEMGroup
on successful.
-
listGroupsUserJoinedWithInfo
public reactor.core.publisher.Mono<java.util.List<JoinGroupResource>> listGroupsUserJoinedWithInfo(java.lang.String username, int pageNum, int pageSize)
分页获取用户加入的所有群组,返回值携带群组信息。初次调用时,
cursor
传null
。之后的调用,cursor
传上次返回的值。API使用示例:
try { List<JoinGroupResource> groupResources = service.group().listGroupsUserJoinedWithInfo("username", 1, 10).block(); if (groupResources != null && groupResources.size() > 0) { groupResources.forEach(groupResource -> { System.out.println("groupId : " + groupResource.getGroupId()); System.out.println("groupName : " + groupResource.getGroupName()); }); } } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
username
- the usernamepageNum
- 当前页码pageSize
- 每页获取已加入的群组数量- 返回:
- 群列表响应或错误
-
getGroup
public reactor.core.publisher.Mono<EMGroup> getGroup(java.lang.String groupId)
获取群详情。API使用示例:
EMService service; try { EMGroup group = service.group().getGroup("groupId").block(); String groupName = group.getName(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群id- 返回:
- 群详情或错误
- 另请参阅:
- 获取群详情
-
getGroupList
public reactor.core.publisher.Mono<java.util.List<EMGroup>> getGroupList(java.util.List<java.lang.String> groupIdList)
获取多个群详情。API使用示例:
EMService service; try { List<String> groupIdList = new ArrayList<>(); groupIdList.add("193100825821185"); groupIdList.add("193100825821186"); List<EMGroup> groupList = service.group().getGroupList(groupIdList).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupIdList
- 群id列表- 返回:
- 群详情或错误
- 另请参阅:
- 获取群详情
-
updateGroup
public reactor.core.publisher.Mono<java.lang.Void> updateGroup(java.lang.String groupId, java.util.function.Consumer<UpdateGroupRequest> customizer)
修改群详情。支持修改的参数见
GroupSettingsUpdateRequest
API使用示例:
比如,更新群最大成员数:
EMService service; try { service.group().updateGroup("1", settings -> settings.maxMembers(100)).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idcustomizer
- 请求定制器- 返回:
- 成功或错误
- 另请参阅:
UpdateGroupRequest
, 修改群详情
-
updateGroupOwner
public reactor.core.publisher.Mono<java.lang.Void> updateGroupOwner(java.lang.String groupId, java.lang.String username)
修改群主。新群主需要已经是群成员,否则会报错EMForbiddenException
。API使用示例:
EMService service; try { service.group().updateGroupOwner("groupId", "username").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusername
- 新群主的用户名- 返回:
- 成功或错误
- 另请参阅:
- 修改群主
-
getGroupAnnouncement
public reactor.core.publisher.Mono<java.lang.String> getGroupAnnouncement(java.lang.String groupId)
获取群公告。API使用示例:
EMService service; try { String groupAnnouncement = service.group().getGroupAnnouncement("groupId").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群id- 返回:
- 群公告或错误
- 另请参阅:
- 获取群公告
-
updateGroupAnnouncement
public reactor.core.publisher.Mono<java.lang.Void> updateGroupAnnouncement(java.lang.String groupId, java.lang.String announcement)
更新群公告。API使用示例:
EMService service; try { service.group().updateGroupAnnouncement("groupId", "announcement").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idannouncement
- 群公告- 返回:
- 成功或错误
- 另请参阅:
- 更新群公告
-
listAllGroupMembers
public reactor.core.publisher.Flux<java.lang.String> listAllGroupMembers(java.lang.String groupId)
获取群全部成员,不包括群组的 Owner。API使用示例:
EMService service; try { List<String> members = service.group().listAllGroupMembers("groupId").collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群id- 返回:
- 每个群成员或错误
- 另请参阅:
- 获取群成员
-
listAllGroupMembers
public reactor.core.publisher.Flux<java.lang.String> listAllGroupMembers(java.lang.String groupId, java.lang.String sort)
获取群全部成员,不包括群组的 Owner。API使用示例:
EMService service; try { List<String> members = service.group().listAllGroupMembers("groupId", "asc").collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idsort
- 群成员排序方法 asc:根据加入顺序升序排序 desc:根据加入顺序降序排序- 返回:
- 每个群成员或错误
- 另请参阅:
- 获取群成员
-
listAllGroupMembersIncludeOwner
public reactor.core.publisher.Flux<java.util.Map<java.lang.String,java.lang.String>> listAllGroupMembersIncludeOwner(java.lang.String groupId, java.lang.String sort)
获取群全部成员,包括群组的 Owner。API使用示例:
EMService service; try { List<Map<String, String>> members = service.group().listAllGroupMembersIncludeOwner("groupId", "asc").collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idsort
- asc:根据加入顺序升序排序 desc:根据加入顺序降序排序- 返回:
- 每个群成员或错误
- 另请参阅:
- 获取群成员
-
listGroupMembersIncludeOwner
public reactor.core.publisher.Mono<java.util.List<java.util.Map<java.lang.String,java.lang.String>>> listGroupMembersIncludeOwner(java.lang.String groupId, int pageNum, int pageSize, java.lang.String sort)
分页获取群组成员列表,包括群组的 Owner。API使用示例:
EMService service; EMPage<String> page = null; try { List<Map<String, String>> members = service.room().listGroupMembersIncludeOwner(groupId, 1, 10, asc).block(); System.out.println("群组成员列表:" + members); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群组idpageNum
- 当前页码。默认从第 1 页开始获取pageSize
- 每页期望返回的群组成员数量。取值范围为[1,100]。默认为 10。sort
- asc:根据加入顺序升序排序 desc:根据加入顺序降序排序- 返回:
- 获取聊天室成员响应或错误
- 另请参阅:
- 获取群成员
-
listGroupMembers
public reactor.core.publisher.Mono<EMPage<java.lang.String>> listGroupMembers(java.lang.String groupId, int limit, java.lang.String cursor)
分页获取群成员。API使用示例:
首次调用时,
cursor
传null
。之后每次调用,cursor
传上次返回的值。比如:
EMService service; EMPage<String> page = null; try { page = service.group().listGroupMembers(groupId, 1, null).block(); List<String> members = page.getValues(); System.out.println("群组成员列表:" + members); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } // ... do something to the members ... if (page != null) { String cursor = page.getCursor(); while (cursor != null) { try { page = service.group().listGroupMembers(groupId, 1, cursor).block(); System.out.println("群组成员列表:" + page.getValues()); // ... do something to the members ... cursor = page.getCursor(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } } }
- 参数:
groupId
- 群idlimit
- 返回多少群成员idcursor
- 开始位置- 返回:
- 获取群成员响应或错误
- 另请参阅:
GroupMemberListResponse
, 获取群成员
-
listGroupMembers
public reactor.core.publisher.Mono<EMPage<java.lang.String>> listGroupMembers(java.lang.String groupId, int limit, java.lang.String cursor, java.lang.String sort)
分页获取群成员。API使用示例:
首次调用时,
cursor
传null
。之后每次调用,cursor
传上次返回的值。比如:
EMService service; EMPage<String> page = null; try { page = service.group().listGroupMembers(groupId, 1, null, "asc").block(); List<String> members = page.getValues(); System.out.println("群组成员列表:" + members); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } // ... do something to the members ... if (page != null) { String cursor = page.getCursor(); while (cursor != null) { try { page = service.group().listGroupMembers(groupId, 1, cursor, "asc").block(); System.out.println("群组成员列表:" + page.getValues()); // ... do something to the members ... cursor = page.getCursor(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); } } }
- 参数:
groupId
- 群idlimit
- 返回多少群成员idcursor
- 开始位置sort
- 群成员排序方法 asc:根据加入顺序升序排序 desc:根据加入顺序降序排序- 返回:
- 获取群成员响应或错误
- 另请参阅:
GroupMemberListResponse
, 获取群成员
-
addGroupMember
public reactor.core.publisher.Mono<java.lang.Void> addGroupMember(java.lang.String groupId, java.lang.String username)
添加群成员(单个)。API使用示例:
EMService service; try { service.group().addGroupMember("groupId", "username").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusername
- 要添加的用户的用户名- 返回:
- 成功或错误
- 另请参阅:
- 添加群成员
-
addGroupMembers
public reactor.core.publisher.Mono<java.lang.Void> addGroupMembers(java.lang.String groupId, java.util.List<java.lang.String> usernames)
添加群成员(多个)。API使用示例:
EMService service; try { List<String> members = new ArrayList<>(); members.add("member1"); members.add("member2"); service.group().addGroupMembers("groupId", members).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusernames
- 要添加的用户的用户名列表- 返回:
- 成功或错误
- 另请参阅:
- 添加群成员(多个)
-
removeGroupMember
public reactor.core.publisher.Mono<java.lang.Void> removeGroupMember(java.lang.String groupId, java.lang.String username)
移除群成员。API使用示例:
EMService service; try { service.group().removeGroupMember("groupId", "username").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusername
- 要移除的用户的用户名- 返回:
- 成功或错误
- 另请参阅:
- 移除群成员
-
removeGroupMembers
public reactor.core.publisher.Mono<java.util.List<EMRemoveMember>> removeGroupMembers(java.lang.String groupId, java.util.List<java.lang.String> usernames)
移除群成员(多个)。API使用示例:
EMService service; try { List<String> members = new ArrayList<>(); members.add("member1"); members.add("member2"); List<EMRemoveMember> removeMembers = service.group().removeGroupMembers("groupId", members).block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusernames
- 要移除的用户的用户名列表- 返回:
- EMRemoveMember或错误
- 另请参阅:
- 移除群成员(多个)
-
listGroupAdmins
public reactor.core.publisher.Flux<java.lang.String> listGroupAdmins(java.lang.String groupId)
获取群全部管理员。API使用示例:
EMService service; try { List<String> admins = service.group().listGroupAdmins("groupId").collectList().block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群id- 返回:
- 每个管理员或错误
- 另请参阅:
- 获取群管理员
-
addGroupAdmin
public reactor.core.publisher.Mono<java.lang.Void> addGroupAdmin(java.lang.String groupId, java.lang.String username)
升级群成员为群管理员。API使用示例:
EMService service; try { service.group().addGroupAdmin("groupId", "username").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusername
- 被升级的群成员的用户名- 返回:
- 成功或错误
- 另请参阅:
- 升级群成员
-
removeGroupAdmin
public reactor.core.publisher.Mono<java.lang.Void> removeGroupAdmin(java.lang.String groupId, java.lang.String username)
降级群管理员为群成员。API使用示例:
EMService service; try { service.group().removeGroupAdmin("groupId", "username").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idusername
- 被降级的群管理员的用户名- 返回:
- 成功或错误
- 另请参阅:
- 降级群管理员
-
assignGroup
public reactor.core.publisher.Mono<java.lang.Void> assignGroup(java.lang.String groupId, java.lang.String newOwner)
转让群组。API使用示例:
EMService service; try { service.group().assignGroup("groupId", "newOwner").block(); } catch (EMException e) { e.getErrorCode(); e.getMessage(); }
- 参数:
groupId
- 群idnewOwner
- 被转让群组的用户名- 返回:
- 成功或错误
- 另请参阅:
- 转让群组
-
-