public class MetadataApi extends Object
构造器和说明 |
---|
MetadataApi(Context context) |
限定符和类型 | 方法和说明 |
---|---|
reactor.core.publisher.Mono<ChatRoomMetadataDeleteResponse> |
deleteChatRoomMetadata(String operator,
String chatroomId,
List<String> keys)
删除聊天室属性
API使用示例:
EMService service;
List<String> keys = new ArrayList<>();
keys.add("nickname");
try {
service.metadata().deleteChatRoomMetadata("operator", "roomId", map, keys).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<ChatRoomMetadataDeleteResponse> |
deleteChatRoomMetadataForced(String chatroomId,
List<String> keys)
强制删除聊天室属性
API使用示例:
EMService service;
List<String> keys = new ArrayList<>();
keys.add("nickname");
try {
service.metadata().deleteChatRoomMetadataForced("roomId", map, keys).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<Boolean> |
deleteMetadataFromUser(String username)
删除用户属性。
|
reactor.core.publisher.Mono<EMMetadata> |
getMetadataFromChatGroupUser(String username,
String groupId)
获取单个群成员的所有自定义属性
API使用示例:
EMService service;
try {
EMMetadata userMetadata = service.metadata().getMetadataFromChatGroup("username", "groupId").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<EMMetadataBatch> |
getMetadataFromChatGroupUsers(String groupId,
List<String> targets,
List<String> properties)
根据属性 key 获取多个群成员的自定义属性
API使用示例:
EMService service;
List<String> targets = new ArrayList<>();
targets.add("user1");
targets.add("user2");
List<String> properties = new ArrayList<>();
properties.add("nickname");
try {
EMMetadataBatch metadataBatch = service.metadata().getMetadataFromUsers("groupId", targets, properties).block();
metadataBatch.getData();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<EMMetadata> |
getMetadataFromUser(String username)
获取用户属性
API使用示例:
EMService service;
try {
EMMetadata userMetadata = service.metadata().getMetadataFromUser("username").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<EMMetadataBatch> |
getMetadataFromUsers(List<String> targets,
List<String> properties)
批量获取用户属性
API使用示例:
EMService service;
List<String> targets = new ArrayList<>();
targets.add("user1");
targets.add("user2");
List<String> properties = new ArrayList<>();
properties.add("nickname");
try {
EMMetadataBatch metadataBatch = service.metadata().getMetadataFromUsers(targets, properties).block();
metadataBatch.getData();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<EMMetadataUsage> |
getUsage()
获取app用户属性当前所占空间。
|
reactor.core.publisher.Mono<ChatRoomMetadataGetResponse> |
listChatRoomMetadata(String chatroomId,
List<String> keys)
获取聊天室属性
API使用示例:
EMService service;
List<String> keys = new ArrayList<>();
keys.add("nickname");
try {
service.metadata().listChatRoomMetadata("roomId", keys).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<ChatRoomMetadataGetResponse> |
listChatRoomMetadataAll(String chatroomId)
获取所有的聊天室属性
API使用示例:
EMService service;
try {
service.metadata().listChatRoomMetadataAll("roomId").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<ChatRoomMetadataSetResponse> |
setChatRoomMetadata(String operator,
String chatroomId,
Map<String,String> metadata,
AutoDelete autoDelete)
设置聊天室属性
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setChatRoomMetadata("username", "roomId", map, AutoDelete.NO_DELETE).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<ChatRoomMetadataSetResponse> |
setChatRoomMetadataForced(String operator,
String chatroomId,
Map<String,String> metadata,
AutoDelete autoDelete)
强制设置聊天室属性
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setChatRoomMetadataToUserForced("username", "roomId", map, AutoDelete.NO_DELETE).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<Void> |
setMetadataToChatGroupUser(String username,
String groupId,
Map<String,String> metadata)
设置群成员自定义属性
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setMetadataToChatGroup("username", "groupId", map).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
reactor.core.publisher.Mono<Void> |
setMetadataToUser(String username,
Map<String,String> metadata)
设置用户属性
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setMetadataToUser("username", map).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
|
public MetadataApi(Context context)
public reactor.core.publisher.Mono<Void> setMetadataToUser(String username, Map<String,String> metadata)
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setMetadataToUser("username", map).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
username
- 要被设置用户属性的用户名metadata
- 要设置的属性public reactor.core.publisher.Mono<EMMetadata> getMetadataFromUser(String username)
API使用示例:
EMService service;
try {
EMMetadata userMetadata = service.metadata().getMetadataFromUser("username").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
username
- 要获取的用户名public reactor.core.publisher.Mono<EMMetadataBatch> getMetadataFromUsers(List<String> targets, List<String> properties)
API使用示例:
EMService service;
List<String> targets = new ArrayList<>();
targets.add("user1");
targets.add("user2");
List<String> properties = new ArrayList<>();
properties.add("nickname");
try {
EMMetadataBatch metadataBatch = service.metadata().getMetadataFromUsers(targets, properties).block();
metadataBatch.getData();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
targets
- 需要获取用户属性的用户名列表,最多 100 个用户名。properties
- 属性名列表,查询结果只返回该列表中包含的属性,不在该列表中的属性将被忽略。public reactor.core.publisher.Mono<EMMetadataUsage> getUsage()
API使用示例:
EMService service;
try {
EMMetadataUsage metadataUsage = service.metadata().getUsage().block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
public reactor.core.publisher.Mono<Boolean> deleteMetadataFromUser(String username)
API使用示例:
EMService service;
try {
Boolean isSuc = service.metadata().deleteMetadataFromUser("username").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
username
- 要被删除用户属性的用户名public reactor.core.publisher.Mono<ChatRoomMetadataSetResponse> setChatRoomMetadata(String operator, String chatroomId, Map<String,String> metadata, AutoDelete autoDelete)
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setChatRoomMetadata("username", "roomId", map, AutoDelete.NO_DELETE).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
operator
- 设置聊天室属性的操作人chatroomId
- 聊天室idmetadata
- 要设置的属性autoDelete
- 用户退出是否删除属性public reactor.core.publisher.Mono<ChatRoomMetadataSetResponse> setChatRoomMetadataForced(String operator, String chatroomId, Map<String,String> metadata, AutoDelete autoDelete)
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setChatRoomMetadataToUserForced("username", "roomId", map, AutoDelete.NO_DELETE).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
chatroomId
- 聊天室idoperator
- 强制设置聊天室属性的操作人metadata
- 要设强制设置的属性autoDelete
- 用户退出是否删除属性public reactor.core.publisher.Mono<ChatRoomMetadataGetResponse> listChatRoomMetadata(String chatroomId, List<String> keys)
API使用示例:
EMService service;
List<String> keys = new ArrayList<>();
keys.add("nickname");
try {
service.metadata().listChatRoomMetadata("roomId", keys).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
chatroomId
- 聊天室idkeys
- 要获取的属性key列表public reactor.core.publisher.Mono<ChatRoomMetadataGetResponse> listChatRoomMetadataAll(String chatroomId)
API使用示例:
EMService service;
try {
service.metadata().listChatRoomMetadataAll("roomId").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
chatroomId
- 聊天室idpublic reactor.core.publisher.Mono<ChatRoomMetadataDeleteResponse> deleteChatRoomMetadata(String operator, String chatroomId, List<String> keys)
API使用示例:
EMService service;
List<String> keys = new ArrayList<>();
keys.add("nickname");
try {
service.metadata().deleteChatRoomMetadata("operator", "roomId", map, keys).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
operator
- 执行删除的操作人chatroomId
- 聊天室idkeys
- 要删除的属性key列表public reactor.core.publisher.Mono<ChatRoomMetadataDeleteResponse> deleteChatRoomMetadataForced(String chatroomId, List<String> keys)
API使用示例:
EMService service;
List<String> keys = new ArrayList<>();
keys.add("nickname");
try {
service.metadata().deleteChatRoomMetadataForced("roomId", map, keys).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
chatroomId
- 聊天室idkeys
- 要强制删除的属性key列表public reactor.core.publisher.Mono<Void> setMetadataToChatGroupUser(String username, String groupId, Map<String,String> metadata)
API使用示例:
EMService service;
Map<String, String> map = new HashMap<>();
map.put("nickname", "昵称");
map.put("avatarurl", "http://www.easemob.com/avatar.png");
map.put("phone", "159");
try {
service.metadata().setMetadataToChatGroup("username", "groupId", map).block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
username
- 要被设置群组属性的用户名groupId
- 要被设置群组属性的群组idmetadata
- 要设置的属性public reactor.core.publisher.Mono<EMMetadata> getMetadataFromChatGroupUser(String username, String groupId)
API使用示例:
EMService service;
try {
EMMetadata userMetadata = service.metadata().getMetadataFromChatGroup("username", "groupId").block();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
username
- 要获取的用户名groupId
- 要获取的群组idpublic reactor.core.publisher.Mono<EMMetadataBatch> getMetadataFromChatGroupUsers(String groupId, List<String> targets, List<String> properties)
API使用示例:
EMService service;
List<String> targets = new ArrayList<>();
targets.add("user1");
targets.add("user2");
List<String> properties = new ArrayList<>();
properties.add("nickname");
try {
EMMetadataBatch metadataBatch = service.metadata().getMetadataFromUsers("groupId", targets, properties).block();
metadataBatch.getData();
} catch (EMException e) {
e.getErrorCode();
e.getMessage();
}
groupId
- 群组idtargets
- 要获取自定义属性的群成员的用户 ID。一次最多可传 10 个用户 ID。properties
- 要获取自定义属性的 key 的数组。若该参数设置为空数组或不传,则获取这些群成员的所有自定义属性。Copyright © 2024. All rights reserved.