Public 成员函数 | |
void | sendMessage (final ChatMessage msg) |
void | ackConversationRead (String conversationId) throws ChatException |
void | ackMessageRead (String to, String messageId) throws ChatException |
void | ackGroupMessageRead (String to, String messageId, String ext) throws ChatException |
void | recallMessage (ChatMessage message) throws ChatException |
void | asyncRecallMessage (final ChatMessage message, final CallBack callback) |
ChatMessage | getMessage (String messageId) |
Conversation | getConversation (String id) |
Conversation | getConversation (String id, ConversationType type) |
Conversation | getConversation (String username, ConversationType type, boolean createIfNotExists) |
Conversation | getConversation (String username, ConversationType type, boolean createIfNotExists, boolean isChatThread) |
void | markAllConversationsAsRead () |
int | getUnreadMessageCount () |
void | saveMessage (ChatMessage message) |
boolean | updateMessage (ChatMessage message) |
void | downloadAttachment (final ChatMessage msg) |
void | downloadThumbnail (final ChatMessage msg) |
synchronized void | importMessages (List< ChatMessage > msgs) |
List< Conversation > | getConversationsByType (ConversationType type) |
Map< String, Conversation > | getAllConversations () |
Map< String, Conversation > | fetchConversationsFromServer () throws ChatException |
void | asyncFetchConversationsFromServer (final ValueCallBack< Map< String, Conversation > > callBack) |
void | asyncFetchConversationsFromServer (int pageNum, int pageSize, final ValueCallBack< Map< String, Conversation > > callBack) |
void | loadAllConversations () |
boolean | deleteConversation (String username, boolean deleteMessages) |
void | deleteConversationFromServer (String username, ConversationType type, boolean isDeleteServerMessages, CallBack deleteCallBack) |
void | addMessageListener (MessageListener listener) |
void | removeMessageListener (MessageListener listener) |
void | addConversationListener (ConversationListener listener) |
void | removeConversationListener (ConversationListener listener) |
void | setVoiceMessageListened (ChatMessage message) |
boolean | updateParticipant (String from, String changeTo) |
CursorResult< GroupReadAck > | fetchGroupReadAcks (String msgId, int pageSize, String startAckId) throws ChatException |
void | asyncFetchGroupReadAcks (final String msgId, final int pageSize, final String startAckId, final ValueCallBack< CursorResult< GroupReadAck > > callBack) |
CursorResult< ChatMessage > | fetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String startMsgId) throws ChatException |
CursorResult< ChatMessage > | fetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String startMsgId, Conversation.SearchDirection direction) throws ChatException |
void | asyncFetchHistoryMessage (final String conversationId, final ConversationType type, final int pageSize, final String startMsgId, final ValueCallBack< CursorResult< ChatMessage > > callBack) |
void | asyncFetchHistoryMessage (final String conversationId, final ConversationType type, final int pageSize, final String startMsgId, final Conversation.SearchDirection direction, final ValueCallBack< CursorResult< ChatMessage > > callBack) |
List< ChatMessage > | searchMsgFromDB (Type type, long timeStamp, int maxCount, String from, Conversation.SearchDirection direction) |
List< ChatMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, Conversation.SearchDirection direction) |
void | deleteMessagesBeforeTimestamp (long timeStamp, CallBack callback) |
void | asyncReportMessage (String msgId, String reportTarget, String reportReason, CallBack callBack) |
void | reportMessage (String msgId, String reportTarget, String reportReason) throws ChatException |
void | fetchSupportLanguages (ValueCallBack< List< Language > > callBack) |
void | translateMessage (ChatMessage message, List< String > languages, ValueCallBack< ChatMessage > callBack) |
void | addReaction (final String messageId, final String reaction) throws ChatException |
void | asyncAddReaction (final String messageId, final String reaction, final CallBack callback) |
void | removeReaction (final String messageId, final String reaction) throws ChatException |
void | asyncRemoveReaction (final String messageId, final String reaction, final CallBack callback) |
Map< String, List< MessageReaction > > | getReactionList (final List< String > messageIdList, final ChatMessage.ChatType chatType, final String groupId) throws ChatException |
void | asyncGetReactionList (final List< String > messageIdList, final ChatMessage.ChatType chatType, final String groupId, final ValueCallBack< Map< String, List< MessageReaction > > > callback) |
CursorResult< MessageReaction > | getReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize) throws ChatException |
void | asyncGetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize, final ValueCallBack< CursorResult< MessageReaction > > callback) |
Protected 成员函数 | |
ChatManager (ChatClient client, EMAChatManager manager, EMAReactionManager reactionManager) | |
void | removeMessagesFromServer (String conversationId, ConversationType type, List< String > msgIdList, CallBack callBack) |
void | removeMessagesFromServer (String conversationId, ConversationType type, long beforeTimeStamp, CallBack callBack) |
聊天管理类,该类负责管理会话(加载,删除等)、发送消息、下载消息附件等。
发送文文本消息示例如下:
void io.agora.chat.ChatManager.ackConversationRead | ( | String | conversationId | ) | throws ChatException |
发送会话的已读回执,该方法只针对单聊会话。
该方法会通知服务器将此会话未读数设置为 0,消息发送方将会收到 ConversationListener#onConversationRead(String, String) 回调。 在多端多设备登录下,接收方的其他设备也会收到该回调。
群消息已读回执,详见 ackGroupMessageRead(String, String, String)。
conversationId | 会话 ID。 |
ChatException | 可能抛出以下异常:Error#USER_NOT_LOGIN、Error#SERVER_NOT_REACHABLE、 Error#MESSAGE_INVALID 等,详见 Error。 |
void io.agora.chat.ChatManager.ackGroupMessageRead | ( | String | to, |
String | messageId, | ||
String | ext | ||
) | throws ChatException |
发送群消息已读回执。
注意
设置了 ChatOptions#setRequireAck(boolean) 和 ChatMessage#setIsNeedGroupAck(boolean) 后才能调用该方法。
发送单聊消息已读回执,详见 ackMessageRead(String, String)
会话已读回执,详见 ackConversationRead(String)。
to | 会话 ID。 |
messageId | 消息 ID。 |
ext | 扩展信息。用户通过定义关键字指定动作或命令。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.ackMessageRead | ( | String | to, |
String | messageId | ||
) | throws ChatException |
发送消息的已读回执。
该方法仅适用于单聊会话,仅在 ChatOptions#setRequireAck(boolean) 为 true
时生效。
发送群消息已读回执,详见 ackGroupMessageRead(String, String, String)。
推荐进入聊天页面的时调用 ackConversationRead(String) ,其他情况下调用该方法以减少调用频率。
to | 接收方的用户 ID。 |
messageId | 消息的 ID。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.addConversationListener | ( | ConversationListener | listener | ) |
注册会话监听器。
会话监听器可监听会话变化及会话已读回执。
在不需要会话监听器时,可调用 removeConversationListener(ConversationListener) 方法移除。
listener | 要添加的会话监听,详见 ConversationListener。 |
void io.agora.chat.ChatManager.addMessageListener | ( | MessageListener | listener | ) |
注册消息监听器。
接收到新消息等回调可以通过设置此方法进行监听。
在不需要消息监听器时,可调用 removeMessageListener(MessageListener) 方法将其移除。
listener | 要注册的消息监听,详见 MessageListener。 |
void io.agora.chat.ChatManager.addReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws ChatException |
添加 Reaction。
同步方法。
messageId | 消息 ID。 |
reaction | 要添加的消息 Reaction。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.asyncAddReaction | ( | final String | messageId, |
final String | reaction, | ||
final CallBack | callback | ||
) |
添加 Reaction。
异步方法。
messageId | 消息 ID。 |
reaction | 要添加的消息 Reaction。 |
callback | 处理结果回调,失败会返回失败原因。详见 CallBack。 |
void io.agora.chat.ChatManager.asyncFetchConversationsFromServer | ( | final ValueCallBack< Map< String, Conversation > > | callBack | ) |
从服务器获取会话列表。
异步方法。
void io.agora.chat.ChatManager.asyncFetchConversationsFromServer | ( | int | pageNum, |
int | pageSize, | ||
final ValueCallBack< Map< String, Conversation > > | callBack | ||
) |
从服务器分页获取会话列表。
异步方法。
pageNum | 当前页码,从 1 开始。 |
pageSize | 每页获取的会话数量,取值范围为 [1,20]。 |
void io.agora.chat.ChatManager.asyncFetchGroupReadAcks | ( | final String | msgId, |
final int | pageSize, | ||
final String | startAckId, | ||
final ValueCallBack< CursorResult< GroupReadAck > > | callBack | ||
) |
从服务器分页获取群组消息已读回执详情。
发送群组消息回执,可调用 ackGroupMessageRead(String, String, String)。
异步方法。
msgId | 消息 ID。 |
pageSize | 每页获取的群消息已读回执数。取值范围为 [1,50]。 |
startAckId | 查询起始的已读回执 ID。该参数设置后,SDK 从指定的已读回执 ID 开始,按服务器接收已读回执的时间的逆序获取。 若该参数为空,SDK 从最新的已读回执开始按服务器接收回执时间的逆序获取。 |
callBack | 结果回调。
|
void io.agora.chat.ChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final ConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final Conversation.SearchDirection | direction, | ||
final ValueCallBack< CursorResult< ChatMessage > > | callBack | ||
) |
从服务器分页获取指定会话的历史消息。
异步方法。
conversationId | 会话 ID。 |
type | 会话类型,详见 ConversationType。 |
pageSize | 每页期望获取的消息数。取值范围为 [1,50]。 |
startMsgId | 查询的起始消息 ID。该参数设置后,SDK 从指定的消息 ID 开始,按消息搜索方向获取。 如果传入消息的 ID 为空,SDK 忽略该参数,按搜索方向查询消息。
|
direction | 消息搜索方向。详见 Conversation.SearchDirection。
|
callBack | 结果回调:
|
void io.agora.chat.ChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final ConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final ValueCallBack< CursorResult< ChatMessage > > | callBack | ||
) |
从服务器分页获取指定会话的历史消息。
异步方法。
conversationId | 会话 ID。 |
type | 会话类型,详见 ConversationType。 |
pageSize | 每页期望获取的消息条数。取值范围为 [1,50]。 |
startMsgId | 查询的起始消息 ID。该参数设置后,SDK 从指定的消息 ID 开始,按服务器接收消息的时间的逆序获取。 若该参数为空,SDK 从最新的消息开始,按服务器接收消息的时间的逆序获取。 |
callBack | 结果回调,成功则执行 ValueCallBack#onSuccess(Object),返回消息列表(不包含查询起始 ID 的消息)和下次查询的 cursor; 失败则执行 ValueCallBack#onError(int, String)。 |
void io.agora.chat.ChatManager.asyncGetReactionDetail | ( | final String | messageId, |
final String | reaction, | ||
final String | cursor, | ||
final int | pageSize, | ||
final ValueCallBack< CursorResult< MessageReaction > > | callback | ||
) |
获取 Reaction 详细信息。
异步方法。
messageId | 消息 ID。 |
reaction | 消息 Reaction。 |
cursor | 查询的起始游标位置。 |
pageSize | 每页期望获取的 Reaction 数。 |
callback | 处理结果回调,包含 cursor 和 MessageReaction 列表(仅使用该列表第一个数据即可)。 |
void io.agora.chat.ChatManager.asyncGetReactionList | ( | final List< String > | messageIdList, |
final ChatMessage.ChatType | chatType, | ||
final String | groupId, | ||
final ValueCallBack< Map< String, List< MessageReaction > > > | callback | ||
) |
获取 Reaction 列表。
异步方法。
messageIdList | 消息 ID。 |
chatType | 会话类型,仅支持单聊(ChatMessage.ChatType#Chat )和群聊(ChatMessage.ChatType#GroupChat)。 |
groupId | 群组 ID,该参数只对群聊生效。 |
callback | 处理结果回调,包含消息 ID 对应的 Reaction 列表(MessageReaction 的用户列表 UserList 为概要数据,只包含前三个用户信息)。 |
void io.agora.chat.ChatManager.asyncRecallMessage | ( | final ChatMessage | message, |
final CallBack | callback | ||
) |
void io.agora.chat.ChatManager.asyncRemoveReaction | ( | final String | messageId, |
final String | reaction, | ||
final CallBack | callback | ||
) |
void io.agora.chat.ChatManager.asyncReportMessage | ( | String | msgId, |
String | reportTarget, | ||
String | reportReason, | ||
CallBack | callBack | ||
) |
举报非法消息。
异步方法。
msgId | 非法消息的 ID。 |
reportTarget | 非法消息标签,如涉政或涉恐。 |
reportReason | 举报原因。 |
callBack | 结果回调,详见 CallBack:
|
boolean io.agora.chat.ChatManager.deleteConversation | ( | String | username, |
boolean | deleteMessages | ||
) |
删除指定会话及其本地历史消息。
username | 会话 ID。 |
deleteMessages | 删除会话时是否同时删除本地的历史消息。
|
true
:是;false
: 否。 void io.agora.chat.ChatManager.deleteConversationFromServer | ( | String | username, |
ConversationType | type, | ||
boolean | isDeleteServerMessages, | ||
CallBack | deleteCallBack | ||
) |
删除服务端的指定会话及其历史消息。
异步方法。
username | 会话 ID。 |
type | 会话类型,详见 ConversationType。 |
isDeleteServerMessages | 删除会话时是否同时删除历史消息。
|
deleteCallBack | 删除服务端会话及其历史消息成功与否的回调。
|
void io.agora.chat.ChatManager.deleteMessagesBeforeTimestamp | ( | long | timeStamp, |
CallBack | callback | ||
) |
删除指定时间戳之前的本地历史消息。
timeStamp | 查询的消息的起始 Unix 时间戳,单位为毫秒。 |
callback | 删除结果回调,详见 CallBack。 |
void io.agora.chat.ChatManager.downloadAttachment | ( | final ChatMessage | msg | ) |
下载消息的附件。
若附件自动下载失败,也可以调用此方法下载。
msg | 要下载附件的消息。 |
void io.agora.chat.ChatManager.downloadThumbnail | ( | final ChatMessage | msg | ) |
下载消息的缩略图。
msg | 要下载缩略图的消息。只有图片消息和视频消息有缩略图。 |
Map< String, Conversation > io.agora.chat.ChatManager.fetchConversationsFromServer | ( | ) | throws ChatException |
从服务器获取会话列表。
该功能需联系商务开通。开通后,用户默认可拉取 7 天内的 10 个会话(每个会话包含最新一条历史消息)。如需调整会话数量或时间限制请联系商务经理。
同步方法,会阻塞当前线程。
CursorResult< GroupReadAck > io.agora.chat.ChatManager.fetchGroupReadAcks | ( | String | msgId, |
int | pageSize, | ||
String | startAckId | ||
) | throws ChatException |
从服务器分页获取群组消息已读回执详情。
发送群组消息回执,可调用 ackGroupMessageRead(String, String, String)。
同步方法,会阻塞当前线程。
msgId | 消息 ID。 |
pageSize | 每页期望返回的群消息已读数。取值范围[1,50]。 |
startAckId | 查询起始的已读回执 ID。该参数设置后,SDK 从指定的已读回执 ID 开始,按服务器接收已读回执的时间的逆序获取。 若该参数为空,SDK 从最新的已读回执开始按服务器接收回执时间的逆序获取。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
CursorResult< ChatMessage > io.agora.chat.ChatManager.fetchHistoryMessages | ( | String | conversationId, |
ConversationType | type, | ||
int | pageSize, | ||
String | startMsgId | ||
) | throws ChatException |
从服务器分页获取指定会话的历史消息。
同步方法,会阻塞当前线程。
conversationId | 会话 ID。 |
type | 会话类型, 详见 ConversationType。 |
pageSize | 每页期望获取的消息条数。取值范围为 [1,50]。 |
startMsgId | 开始获取的消息 ID。该参数设置后,SDK 从指定的消息 ID 开始,按服务器接收消息的时间的逆序获取。 若该参数为空,SDK 从最新的消息开始,按服务器接收消息的时间的逆序获取。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
CursorResult< ChatMessage > io.agora.chat.ChatManager.fetchHistoryMessages | ( | String | conversationId, |
ConversationType | type, | ||
int | pageSize, | ||
String | startMsgId, | ||
Conversation.SearchDirection | direction | ||
) | throws ChatException |
从服务器分页获取指定会话的历史消息。
同步方法,会阻塞当前线程。
conversationId | 会话 ID。 |
type | 会话类型, 详见 ConversationType。 |
pageSize | 每页期望获取的消息条数。取值范围为 [1,50]。 |
startMsgId | 查询的起始消息 ID。该参数设置后,SDK 从指定的消息 ID 开始,按消息检索方向获取。如果传入消息的 ID 为空,SDK 忽略该参数,按搜索方向查询消息。
|
direction | 消息检索方向。详见 Conversation.SearchDirection。
|
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.fetchSupportLanguages | ( | ValueCallBack< List< Language > > | callBack | ) |
获取翻译服务支持的语言。
callBack | 结果回调,详见 CallBack。
|
Map< String, Conversation > io.agora.chat.ChatManager.getAllConversations | ( | ) |
获取本地当前所有会话。
该方法会先从内存中获取,如果未找到任何会话,从本地数据库获取。
Conversation io.agora.chat.ChatManager.getConversation | ( | String | id | ) |
获取指定 ID 的会话对象。
id | 会话 ID。 |
Conversation io.agora.chat.ChatManager.getConversation | ( | String | id, |
ConversationType | type | ||
) |
根据会话 ID 以及会话类型获取会话。
没有找到返回空值。
id | 会话 ID。
|
type | 会话类型,详见 ConversationType。 |
Conversation io.agora.chat.ChatManager.getConversation | ( | String | username, |
ConversationType | type, | ||
boolean | createIfNotExists | ||
) |
根据会话 ID 和会话类型获取会话。
username | 会话 ID。
|
type | 会话类型,详见 ConversationType。 |
createIfNotExists | 未找到指定会话时是否创建一个新会话。
|
Conversation io.agora.chat.ChatManager.getConversation | ( | String | username, |
ConversationType | type, | ||
boolean | createIfNotExists, | ||
boolean | isChatThread | ||
) |
根据会话 ID 以及会话类型获取会话。
username | 会话 ID。
|
type | 会话类型,详见 ConversationType。 |
createIfNotExists | 未找到指定会话时是否创建一个新会话。
|
isChatThread | 是否查找子区会话。
|
List< Conversation > io.agora.chat.ChatManager.getConversationsByType | ( | ConversationType | type | ) |
ChatMessage io.agora.chat.ChatManager.getMessage | ( | String | messageId | ) |
获取指定 ID 的消息对象。
messageId | 消息 ID。 |
CursorResult< MessageReaction > io.agora.chat.ChatManager.getReactionDetail | ( | final String | messageId, |
final String | reaction, | ||
final String | cursor, | ||
final int | pageSize | ||
) | throws ChatException |
获取 Reaction 详细信息。
同步方法。
messageId | 消息 ID。 |
reaction | 消息 Reaction 内容。 |
cursor | 查询的起始游标位置。 |
pageSize | 每页期望获取的 Reaction 数。 |
cursor
为空表示数据已全部获取。 Map< String, List< MessageReaction > > io.agora.chat.ChatManager.getReactionList | ( | final List< String > | messageIdList, |
final ChatMessage.ChatType | chatType, | ||
final String | groupId | ||
) | throws ChatException |
获取 Reaction 列表。
同步方法。
messageIdList | 消息 ID。 |
chatType | 会话类型,仅支持单聊(ChatMessage.ChatType#Chat)和群聊(ChatMessage.ChatType#GroupChat)。 |
groupId | 群组 ID,该参数仅对群聊生效。 |
MessageReaction
的用户列表 UserList
为概要数据,只包含前三个用户信息)。 int io.agora.chat.ChatManager.getUnreadMessageCount | ( | ) |
获取未读消息数。
synchronized void io.agora.chat.ChatManager.importMessages | ( | List< ChatMessage > | msgs | ) |
将消息导入本地数据库。
你只能将你发送或接收的消息导入本地数据库。
推荐一次导入 1,000 条以内的数据。
msgs | 需要导入数据库的消息。 |
void io.agora.chat.ChatManager.loadAllConversations | ( | ) |
从数据库加载本地所有的会话到内存中。
一般在登录成功后使用此方法,可以加快会话列表的加载速度。
void io.agora.chat.ChatManager.markAllConversationsAsRead | ( | ) |
将所有会话都设成已读。
该方法仅适用于本地会话。
void io.agora.chat.ChatManager.recallMessage | ( | ChatMessage | message | ) | throws ChatException |
撤回发送成功的消息。
若消息发送和撤回时接收方为离线状态,接收方会收到消息撤回回调 MessageListener#onMessageRecalled,不会收到该消息。
同步方法,会阻塞当前线程。
message | 消息对象。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.removeConversationListener | ( | ConversationListener | listener | ) |
移除会话监听器。
调用 addConversationListener(ConversationListener) 添加会话监听器后再调用本方法移除。
listener | 要移除的会话监听器,详见 ConversationListener。 |
void io.agora.chat.ChatManager.removeMessageListener | ( | MessageListener | listener | ) |
移除消息监听器。
调用 addMessageListener(MessageListener) 添加消息监听后再调用本方法移除。
listener | 要移除的监听器,详见 MessageListener。 |
|
protected |
单向删除漫游消息 (根据msgId删除)
conversationId | 会话ID |
type | 会话类型 |
msgIdList | msgId列表 |
callBack | 处理结果回调,详见 CallBack。 |
|
protected |
单向删除漫游消息 (根据时间节点删除 只提供向上删除)
conversationId | 会话ID |
type | 会话类型 |
beforeTimeStamp | 时间节点(毫秒) |
callBack | 处理结果回调,详见 CallBack。 |
void io.agora.chat.ChatManager.removeReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws ChatException |
删除 Reaction。
同步方法。
messageId | 消息 ID。 |
reaction | 要删除的 Reaction。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.reportMessage | ( | String | msgId, |
String | reportTarget, | ||
String | reportReason | ||
) | throws ChatException |
举报非法消息。
同步方法,会阻塞当前线程。
msgId | 非法消息的 ID。 |
reportTarget | 非法消息标签,如涉政或涉恐。 |
reportReason | 举报原因。 |
ChatException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 Error。 |
void io.agora.chat.ChatManager.saveMessage | ( | ChatMessage | message | ) |
List< ChatMessage > io.agora.chat.ChatManager.searchMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
Conversation.SearchDirection | direction | ||
) |
从本地数据库获取指定会话中包含特定关键字的消息。
keywords | 查询关键字。 |
timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
from | 单聊或群聊中的消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息。 |
direction | 消息搜索方向。详见 Conversation.SearchDirection。
|
List< ChatMessage > io.agora.chat.ChatManager.searchMsgFromDB | ( | Type | type, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
Conversation.SearchDirection | direction | ||
) |
从本地数据库获取指定会话的一定数量的特定类型的消息。
type | 消息类型。详见 Type。 |
timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
from | 单聊或群聊中的消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息。 |
direction | 消息搜索方向。详见 Conversation.SearchDirection。
|
void io.agora.chat.ChatManager.sendMessage | ( | final ChatMessage | msg | ) |
发送消息。
如果是语音,图片类等有附件的消息,SDK 会自动上传附件。
可以通过 ChatOptions#setAutoTransferMessageAttachments(boolean) 设置是否上传到聊天服务器。
发送消息的状态,可以通过设置 ChatMessage#setMessageStatusCallback(CallBack) 进行监听。
msg | 要发送的消息,必填。 |
void io.agora.chat.ChatManager.setVoiceMessageListened | ( | ChatMessage | message | ) |
将语音消息设置为已听。
message | 要设置的消息对象。 |
void io.agora.chat.ChatManager.translateMessage | ( | ChatMessage | message, |
List< String > | languages, | ||
ValueCallBack< ChatMessage > | callBack | ||
) |
翻译一条文本消息。
message | 要翻译的消息对象。 |
languages | 目标语言代码列表。 |
callBack | 结果回调,详见 CallBack。
|
boolean io.agora.chat.ChatManager.updateMessage | ( | ChatMessage | message | ) |
更新本地消息。
该方法会同时更新本地内存和数据库中的消息。
message | 要更新的消息对象。 |
boolean io.agora.chat.ChatManager.updateParticipant | ( | String | from, |
String | changeTo | ||
) |
将数据库中指定联系人的相关信息变更成另外一个联系人。
注意
from | 原联系人的用户 ID。 |
changeTo | 新联系人的用户 ID。 |
false
。