hyphenate_SDK3.0 3.9.4
hyphenate java IM SDK
|
Public 成员函数 | |
void | sendMessage (final EMMessage msg) |
void | ackConversationRead (String conversationId) throws HyphenateException |
void | ackMessageRead (String to, String messageId) throws HyphenateException |
void | ackGroupMessageRead (String to, String messageId, String ext) throws HyphenateException |
void | recallMessage (EMMessage message) throws HyphenateException |
void | aysncRecallMessage (final EMMessage message, final EMCallBack callback) |
EMMessage | getMessage (String messageId) |
EMConversation | getConversation (String id) |
EMConversation | getConversation (String id, EMConversationType type) |
EMConversation | getConversation (String username, EMConversationType type, boolean createIfNotExists) |
EMConversation | getConversation (String username, EMConversationType type, boolean createIfNotExists, boolean isChatThread) |
void | markAllConversationsAsRead () |
int | getUnreadMsgsCount () |
int | getUnreadMessageCount () |
void | saveMessage (EMMessage message) |
boolean | updateMessage (EMMessage message) |
void | downloadAttachment (final EMMessage msg) |
void | downloadThumbnail (final EMMessage msg) |
synchronized void | importMessages (List< EMMessage > msgs) |
List< EMConversation > | getConversationsByType (EMConversationType type) |
void | downloadFile (final String remoteUrl, final String localFilePath, final Map< String, String > headers, final EMCallBack callback) |
Map< String, EMConversation > | getAllConversations () |
Map< String, EMConversation > | fetchConversationsFromServer () throws HyphenateException |
void | asyncFetchConversationsFromServer (final EMValueCallBack< Map< String, EMConversation > > callBack) |
void | loadAllConversations () |
boolean | deleteConversation (String username, boolean deleteMessages) |
void | deleteConversationFromServer (String username, EMConversationType type, boolean isDeleteServerMessages, EMCallBack deleteCallBack) |
void | addMessageListener (EMMessageListener listener) |
void | removeMessageListener (EMMessageListener listener) |
void | addConversationListener (EMConversationListener listener) |
void | removeConversationListener (EMConversationListener listener) |
void | setMessageListened (EMMessage message) |
void | setVoiceMessageListened (EMMessage message) |
boolean | updateParticipant (String from, String changeTo) |
EMCursorResult< EMGroupReadAck > | fetchGroupReadAcks (String msgId, int pageSize, String startAckId) throws HyphenateException |
void | asyncFetchGroupReadAcks (final String msgId, final int pageSize, final String startAckId, final EMValueCallBack< EMCursorResult< EMGroupReadAck > > callBack) |
EMCursorResult< EMMessage > | fetchHistoryMessages (String conversationId, EMConversationType type, int pageSize, String startMsgId) throws HyphenateException |
EMCursorResult< EMMessage > | fetchHistoryMessages (String conversationId, EMConversationType type, int pageSize, String startMsgId, EMConversation.EMSearchDirection direction) throws HyphenateException |
void | asyncFetchHistoryMessage (final String conversationId, final EMConversationType type, final int pageSize, final String startMsgId, final EMValueCallBack< EMCursorResult< EMMessage > > callBack) |
void | asyncFetchHistoryMessage (final String conversationId, final EMConversationType type, final int pageSize, final String startMsgId, final EMConversation.EMSearchDirection direction, final EMValueCallBack< EMCursorResult< EMMessage > > callBack) |
List< EMMessage > | searchMsgFromDB (EMMessage.Type type, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction) |
List< EMMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMConversation.EMSearchDirection direction) |
void | deleteMessagesBeforeTimestamp (long timeStamp, EMCallBack callback) |
void | asyncReportMessage (String msgId, String reportTarget, String reportReason, EMCallBack callBack) |
void | reportMessage (String msgId, String reportTarget, String reportReason) throws HyphenateException |
void | fetchSupportLanguages (EMValueCallBack< List< EMLanguage > > callBack) |
void | translateMessage (EMMessage message, List< String > languages, EMValueCallBack< EMMessage > callBack) |
void | addReaction (final String messageId, final String reaction) throws HyphenateException |
void | asyncAddReaction (final String messageId, final String reaction, final EMCallBack callback) |
void | removeReaction (final String messageId, final String reaction) throws HyphenateException |
void | asyncRemoveReaction (final String messageId, final String reaction, final EMCallBack callback) |
Map< String, List< EMMessageReaction > > | getReactionList (final List< String > messageIdList, final EMMessage.ChatType chatType, final String groupId) throws HyphenateException |
void | asyncGetReactionList (final List< String > messageIdList, final EMMessage.ChatType chatType, final String groupId, final EMValueCallBack< Map< String, List< EMMessageReaction > > > callback) |
EMCursorResult< EMMessageReaction > | getReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize) throws HyphenateException |
void | asyncGetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize, final EMValueCallBack< EMCursorResult< EMMessageReaction > > callback) |
Protected 成员函数 | |
EMChatManager (EMClient client, EMAChatManager manager, EMAReactionManager reactionManager) | |
聊天管理类,该类负责管理会话(加载,删除等)、发送消息、下载消息附件等。
比如,发送一条文本消息:
void com.hyphenate.chat.EMChatManager.ackConversationRead | ( | String | conversationId | ) | throws HyphenateException |
发送会话的已读回执,该方法只针对单聊会话。
该方法会通知服务器将此会话未读数设置为 0,对话方(包含多端多设备)将会在下面这个回调方法中接收到回调:
EMConversationListener#onConversationRead(String, String) 。
参考: 群消息已读回执,详见 ackGroupMessageRead(String, String, String)。
conversationId | 会话 ID。 |
HyphenateException | 以下为可能抛出的异常:EMError#USER_NOT_LOGIN、EMError#SERVER_NOT_REACHABLE、 EMError#MESSAGE_INVALID 等,详见 EMError。 |
void com.hyphenate.chat.EMChatManager.ackGroupMessageRead | ( | String | to, |
String | messageId, | ||
String | ext | ||
) | throws HyphenateException |
发送群消息已读回执。
前提条件:设置了 EMOptions#setRequireAck(boolean) 和 EMMessage#setIsNeedGroupAck(boolean)。
参考: 发送单聊消息已读回执,详见 ackMessageRead(String, String) ; 会话已读回执,详见 ackConversationRead(String)。
to | 会话 ID。 |
messageId | 消息 ID。 |
ext | 扩展信息。ext 属性是用户自己定义的关键字,接收后,解析出自定义的字符串,可以自行处理。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
void com.hyphenate.chat.EMChatManager.ackMessageRead | ( | String | to, |
String | messageId | ||
) | throws HyphenateException |
发送消息的已读回执。
该方法仅适用于单聊会话。
注意:如果设置 EMOptions#setRequireAck(boolean) 为 false
,当前方法将失效。
发送群消息已读回执,详见 ackGroupMessageRead(String, String, String)。
建议:在进入聊天页面的时调用 ackConversationRead(String) ,其他场景再调用此方法,可以大量减少调用此方法的次数。
to | 接收方的用户名。 |
messageId | 消息的 ID。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
void com.hyphenate.chat.EMChatManager.addConversationListener | ( | EMConversationListener | listener | ) |
注册会话监听。
用于监听会话变化及监听会话已读回执,详见 EMConversationListener。
需要配合 removeConversationListener(EMConversationListener) 使用。
listener | 要添加的会话监听,详见 EMConversationListener。 |
void com.hyphenate.chat.EMChatManager.addMessageListener | ( | EMMessageListener | listener | ) |
注册消息监听。
接受到新消息等回调可以通过设置此方法进行监听,详见 EMMessageListener。
如果需要移除监听,可以和 removeMessageListener(EMMessageListener) 方法配合使用。
listener | 要注册的消息监听,详见 EMMessageListener。 |
void com.hyphenate.chat.EMChatManager.addReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws HyphenateException |
添加 Reaction。
同步方法。
messageId | 消息 ID。 |
reaction | 消息 Reaction 内容。 |
void com.hyphenate.chat.EMChatManager.asyncAddReaction | ( | final String | messageId, |
final String | reaction, | ||
final EMCallBack | callback | ||
) |
void com.hyphenate.chat.EMChatManager.asyncFetchConversationsFromServer | ( | final EMValueCallBack< Map< String, EMConversation > > | callBack | ) |
从服务器获取会话列表。 该功能需联系商务开通,开通后,用户默认可拉取 7 天内的 10 个会话(每个会话包含最新一条历史消息),如需调整会话数量或时间限制请联系商务经理。
异步方法。
void com.hyphenate.chat.EMChatManager.asyncFetchGroupReadAcks | ( | final String | msgId, |
final int | pageSize, | ||
final String | startAckId, | ||
final EMValueCallBack< EMCursorResult< EMGroupReadAck > > | callBack | ||
) |
从服务器获取群组消息回执详情。
分页获取。
参考: 发送群组消息回执,详见 ackGroupMessageRead(String, String, String)。
异步方法。
msgId | 消息 ID。 |
pageSize | 每页获取群消息已读回执的条数。 |
startAckId | 已读回执的 ID,如果为空,从最新的回执向前开始获取。 |
callBack | 结果回调,成功执行 EMValueCallBack#onSuccess(Object),失败执行 EMValueCallBack#onError(int, String)。 |
void com.hyphenate.chat.EMChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final EMConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final EMConversation.EMSearchDirection | direction, | ||
final EMValueCallBack< EMCursorResult< EMMessage > > | callBack | ||
) |
从服务器获取历史消息。
分页获取。
异步方法。
conversationId | 会话 ID。 |
type | 会话类型,详见 EMConversationType。 |
pageSize | 每页获取的条数。 |
startMsgId | 漫游消息的开始消息 ID,如果为空,根据 direction , 当检索方向为 com.hyphenate.chat.EMConversation.EMSearchDirection#UP 时, 从最新的消息向前开始获取;当检索方向为 com.hyphenate.chat.EMConversation.EMSearchDirection#DOWN 时, 从最旧的消息向后开始获取。 |
direction | 漫游消息检索方向,com.hyphenate.chat.EMConversation.EMSearchDirection#UP为检索 时间戳消息小于开始消息时间戳的消息,com.hyphenate.chat.EMConversation.EMSearchDirection#DOWN 为检索时间戳消息大于开始消息时间戳的消息。 |
callBack | 结果回调,成功则执行 EMValueCallBack#onSuccess(Object), 返回消息列表和用于继续获取历史消息的 Cursor; 失败则执行 EMValueCallBack#onError(int, String)。 |
void com.hyphenate.chat.EMChatManager.asyncFetchHistoryMessage | ( | final String | conversationId, |
final EMConversationType | type, | ||
final int | pageSize, | ||
final String | startMsgId, | ||
final EMValueCallBack< EMCursorResult< EMMessage > > | callBack | ||
) |
从服务器获取历史消息。
分页获取。
异步方法。
conversationId | 会话 ID。 |
type | 会话类型,详见 EMConversationType。 |
pageSize | 每页获取的条数。 |
startMsgId | 漫游消息的开始消息 ID,如果为空,从最新的消息向前开始获取。 |
callBack | 结果回调,成功则执行 EMValueCallBack#onSuccess(Object), 返回消息列表和用于继续获取历史消息的 Cursor; 失败则执行 EMValueCallBack#onError(int, String)。 |
void com.hyphenate.chat.EMChatManager.asyncGetReactionDetail | ( | final String | messageId, |
final String | reaction, | ||
final String | cursor, | ||
final int | pageSize, | ||
final EMValueCallBack< EMCursorResult< EMMessageReaction > > | callback | ||
) |
获取 Reaction 详细信息。
异步方法。
messageId | 消息 ID。 |
reaction | 消息 Reaction。 |
cursor | 查询 cursor。 |
pageSize | 每页获取的 Reaction 条数。 |
callback | 处理结果回调,包含 cursor 和 EMMessageReaction 列表(仅使用该列表第一个数据即可)。 |
void com.hyphenate.chat.EMChatManager.asyncGetReactionList | ( | final List< String > | messageIdList, |
final EMMessage.ChatType | chatType, | ||
final String | groupId, | ||
final EMValueCallBack< Map< String, List< EMMessageReaction > > > | callback | ||
) |
获取 Reaction 列表。
异步方法。
messageIdList | 消息 ID。 |
chatType | 会话类型,仅支持单聊( EMMessage.ChatType#Chat )和群聊(EMMessage.ChatType#GroupChat)。 |
groupId | 群组 ID,该参数只在群聊生效。 |
callback | 处理结果回调,包含消息 ID 对应的 Reaction 列表(EMMessageReaction 的用户列表为概要数据,只包含前三个用户信息)。 |
void com.hyphenate.chat.EMChatManager.asyncRemoveReaction | ( | final String | messageId, |
final String | reaction, | ||
final EMCallBack | callback | ||
) |
void com.hyphenate.chat.EMChatManager.asyncReportMessage | ( | String | msgId, |
String | reportTarget, | ||
String | reportReason, | ||
EMCallBack | callBack | ||
) |
举报违规消息
msgId | 违规的消息id。 |
reportTarget | 举报类型(例如:涉黄、涉恐) |
reportReason | 举报原因。 |
callBack | 执行上报结果 成功执行 EMCallBack#onSuccess(),失败执行EMCallBack#onError(int, String) |
void com.hyphenate.chat.EMChatManager.aysncRecallMessage | ( | final EMMessage | message, |
final EMCallBack | callback | ||
) |
boolean com.hyphenate.chat.EMChatManager.deleteConversation | ( | String | username, |
boolean | deleteMessages | ||
) |
删除指定 ID 的对话和本地的聊天记录。 如果将 deleteMessages
设为 true
,删除会话的同时也会删除本地的聊天记录。
username | 会话 ID。 |
deleteMessages | 是否同时删除本地的聊天记录。
|
删除会话结果。
true
代表删除成功;
false
代表删除失败。
void com.hyphenate.chat.EMChatManager.deleteConversationFromServer | ( | String | username, |
EMConversationType | type, | ||
boolean | isDeleteServerMessages, | ||
EMCallBack | deleteCallBack | ||
) |
删除服务端的指定 ID 的对话和聊天记录,内部异步操作。
username | 会话 ID。 |
type | 会话类型 EMConversationType |
isDeleteServerMessages | 是否同时删除服务端的聊天记录。
|
deleteCallBack | 删除服务端会话与记录成功与否的回调。
|
void com.hyphenate.chat.EMChatManager.deleteMessagesBeforeTimestamp | ( | long | timeStamp, |
EMCallBack | callback | ||
) |
删除时间戳之前的本地消息记录。
timeStamp | Unix 时间戳,单位为毫秒。 |
callback | 删除结果回调,详见 EMCallBack。 |
void com.hyphenate.chat.EMChatManager.downloadAttachment | ( | final EMMessage | msg | ) |
下载消息的附件。
未成功下载的附件,可调用此方法再次下载。
msg | 要下载附件的消息。 |
void com.hyphenate.chat.EMChatManager.downloadFile | ( | final String | remoteUrl, |
final String | localFilePath, | ||
final Map< String, String > | headers, | ||
final EMCallBack | callback | ||
) |
从服务器下载文件。
remoteUrl | 服务器上的远程文件路径。 |
localFilePath | 本地要生成的文件路径。 |
headers | 请求头。 |
callback | 下载结果回调,详见 EMCallBack。 |
void com.hyphenate.chat.EMChatManager.downloadThumbnail | ( | final EMMessage | msg | ) |
下载消息的缩略图。
msg | 要下载缩略图的消息,一般图片消息和视频消息有缩略图。 |
Map< String, EMConversation > com.hyphenate.chat.EMChatManager.fetchConversationsFromServer | ( | ) | throws HyphenateException |
从服务器获取会话列表。 该功能需联系商务开通,开通后,用户默认可拉取 7 天内的 10 个会话(每个会话包含最新一条历史消息),如需调整会话数量或时间限制请联系商务经理。
同步方法,会阻塞当前线程。
EMCursorResult< EMGroupReadAck > com.hyphenate.chat.EMChatManager.fetchGroupReadAcks | ( | String | msgId, |
int | pageSize, | ||
String | startAckId | ||
) | throws HyphenateException |
从服务器获取群组消息回执详情。
分页获取。
参考: 发送群组消息回执,详见 ackGroupMessageRead(String, String, String)。
同步方法,会阻塞当前线程。
msgId | 需要获取回执的消息 ID。 |
pageSize | 每次获取群消息已读回执的条数。 |
startAckId | 已读回执的 ID,可以为空。如果为空,从最新的回执向前开始获取。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
EMCursorResult< EMMessage > com.hyphenate.chat.EMChatManager.fetchHistoryMessages | ( | String | conversationId, |
EMConversationType | type, | ||
int | pageSize, | ||
String | startMsgId | ||
) | throws HyphenateException |
从服务器获取历史消息。
分页获取。
同步方法,会阻塞当前线程。
conversationId | 会话 ID。 |
type | 会话类型, 详见 EMConversationType。 |
pageSize | 每页获取的条数。 |
startMsgId | 漫游消息的开始消息 ID,如果为空,从最新的消息向前开始获取。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
EMCursorResult< EMMessage > com.hyphenate.chat.EMChatManager.fetchHistoryMessages | ( | String | conversationId, |
EMConversationType | type, | ||
int | pageSize, | ||
String | startMsgId, | ||
EMConversation.EMSearchDirection | direction | ||
) | throws HyphenateException |
从服务器获取历史消息。
分页获取。
同步方法,会阻塞当前线程。
conversationId | 会话 ID。 |
type | 会话类型, 详见 EMConversationType。 |
pageSize | 每页获取的条数。 |
startMsgId | 漫游消息的开始消息 ID,如果为空,根据 direction , 当检索方向为 com.hyphenate.chat.EMConversation.EMSearchDirection#UP 时, 从最新的消息向前开始获取;当检索方向为 com.hyphenate.chat.EMConversation.EMSearchDirection#DOWN 时, 从最旧的消息向后开始获取。 |
direction | 漫游消息检索方向,com.hyphenate.chat.EMConversation.EMSearchDirection#UP为检索 时间戳消息小于开始消息时间戳的消息,com.hyphenate.chat.EMConversation.EMSearchDirection#DOWN 为检索时间戳消息大于开始消息时间戳的消息。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
void com.hyphenate.chat.EMChatManager.fetchSupportLanguages | ( | EMValueCallBack< List< EMLanguage > > | callBack | ) |
获取翻译服务支持的语言
callBack | 完成回调 |
Map< String, EMConversation > com.hyphenate.chat.EMChatManager.getAllConversations | ( | ) |
从本地获取当前所有的会话。
先从内存中加载,如果内存中没有再从数据库中加载。
EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | id | ) |
获取定义 ID 的会话对象。
没有找到会返回空值。
id | 会话 ID。 |
EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | id, |
EMConversationType | type | ||
) |
根据会话 ID 以及会话类型获取会话。
没有找到返回空值。
id | 会话 ID。 |
type | 会话类型。 |
EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | username, |
EMConversationType | type, | ||
boolean | createIfNotExists | ||
) |
根据用户或群组 ID 以及会话类型获取会话。
没有找到的话,可以根据 createIfNotExists 的值返回一个新建对象或者空对象。
username | 会话 ID。 |
type | 会话类型。 |
createIfNotExists | 没找到相应会话时是否自动创建。
|
EMConversation com.hyphenate.chat.EMChatManager.getConversation | ( | String | username, |
EMConversationType | type, | ||
boolean | createIfNotExists, | ||
boolean | isChatThread | ||
) |
根据用户或群组id以及会话类型获取会话。
没有找到的话,根据createIfNotExists的值返回一个新建对象或者空对象。
username | 会话ID。 |
type | 会话类型。 |
createIfNotExists | 没找到相应会话时是否自动创建。
|
isChatThread | 是否查找子区会话。
|
List< EMConversation > com.hyphenate.chat.EMChatManager.getConversationsByType | ( | EMConversationType | type | ) |
EMMessage com.hyphenate.chat.EMChatManager.getMessage | ( | String | messageId | ) |
获取指定 ID 的消息对象。
messageId | 消息 ID。 |
EMCursorResult< EMMessageReaction > com.hyphenate.chat.EMChatManager.getReactionDetail | ( | final String | messageId, |
final String | reaction, | ||
final String | cursor, | ||
final int | pageSize | ||
) | throws HyphenateException |
获取 Reaction 详细信息。
同步方法。
messageId | 消息 ID。 |
reaction | 消息 Reaction 内容。 |
cursor | 查询 cursor。 |
pageSize | 每页获取的 Reaction 条数。 |
cursor | 返回 cursor 和 EMMessageReaction 列表(仅使用该列表第一个数据即可)。cursor 为空值说明数据已全部获取到。 |
Map< String, List< EMMessageReaction > > com.hyphenate.chat.EMChatManager.getReactionList | ( | final List< String > | messageIdList, |
final EMMessage.ChatType | chatType, | ||
final String | groupId | ||
) | throws HyphenateException |
获取 Reaction 列表。
同步方法。
messageIdList | 消息 ID。 |
chatType | 会话类型,仅支持单聊( EMMessage.ChatType#Chat )和群聊(EMMessage.ChatType#GroupChat)。 |
groupId | 群组 ID,该参数只在群聊生效。 |
int com.hyphenate.chat.EMChatManager.getUnreadMessageCount | ( | ) |
获取未读消息数。
int com.hyphenate.chat.EMChatManager.getUnreadMsgsCount | ( | ) |
synchronized void com.hyphenate.chat.EMChatManager.importMessages | ( | List< EMMessage > | msgs | ) |
向消息数据库导入多条聊天记录。 在调用此函数时要保证,消息的发送方或者接收方是当前用户。 已经对函数做过速度优化,推荐一次导入 1,000 条以内的数据。
msgs | 需要导入数据库的消息。 |
void com.hyphenate.chat.EMChatManager.loadAllConversations | ( | ) |
从数据库加载本地所有的会话到内存中。 一般在登录成功后使用此方法,可以加快会话列表的加载速度。
void com.hyphenate.chat.EMChatManager.markAllConversationsAsRead | ( | ) |
把所有的会话都设成已读。
这里针对的是本地会话。
void com.hyphenate.chat.EMChatManager.recallMessage | ( | EMMessage | message | ) | throws HyphenateException |
void com.hyphenate.chat.EMChatManager.removeConversationListener | ( | EMConversationListener | listener | ) |
移除会话监听。
如果想要移除会话监听,需要先添加 addConversationListener(EMConversationListener) 后调用此方法进行移除。
listener | 准备移除的会话监听,详见 EMConversationListener。 |
void com.hyphenate.chat.EMChatManager.removeMessageListener | ( | EMMessageListener | listener | ) |
移除消息监听。
需要先添加 addMessageListener(EMMessageListener) 监听,再调用本方法。
listener | 要移除的监听,详见 EMMessageListener。 |
void com.hyphenate.chat.EMChatManager.removeReaction | ( | final String | messageId, |
final String | reaction | ||
) | throws HyphenateException |
删除 Reaction。
同步方法。
messageId | 消息 ID。 |
reaction | 消息 Reaction。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
void com.hyphenate.chat.EMChatManager.reportMessage | ( | String | msgId, |
String | reportTarget, | ||
String | reportReason | ||
) | throws HyphenateException |
举报违规消息。
同步方法,会阻塞当前线程。
msgId | 违规的消息id。 |
reportTarget | 举报类型(例如:涉黄、涉恐) |
reportReason | 举报原因。 |
HyphenateException | 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 |
void com.hyphenate.chat.EMChatManager.saveMessage | ( | EMMessage | message | ) |
保存消息到本地。 比如系统提示消息会存到内存中的会话和数据库。
注意: CMD 类型数据不保存在本地。
message | 待存储的消息。 |
List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB | ( | EMMessage.Type | type, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
EMConversation.EMSearchDirection | direction | ||
) |
根据传入的参数从本地存储中搜索指定数量的消息。
注意:当 maxCount 非常大时,需要考虑内存消耗,目前限制一次最多搜索 400 条数据。
type | 消息类型,文本、图片、语音、视频等,详见 EMMessage.Type。 |
timeStamp | 搜索消息的时间点,Unix 时间戳。 |
maxCount | 搜索结果的最大条数。 |
from | 搜索来自某人或者某群的消息,一般是指会话 ID。 |
List< EMMessage > com.hyphenate.chat.EMChatManager.searchMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
EMConversation.EMSearchDirection | direction | ||
) |
根据传入的参数从本地存储中搜索指定数量的消息。
注意:当 maxCount 非常大时,需要考虑内存消耗,目前限制一次最多搜索 400 条数据。
keywords | 搜索消息中的关键词。 |
timeStamp | 搜索消息的时间点。 |
maxCount | 一次搜索结果的最大条数。 |
from | 搜索来自某人或者某群的消息,一般是指会话 ID。 |
void com.hyphenate.chat.EMChatManager.sendMessage | ( | final EMMessage | msg | ) |
发送消息。
参考: 如果是语音,图片类等有附件的消息,SDK 会自动上传附件。 可以通过 EMOptions#setAutoTransferMessageAttachments(boolean) 设置是否上传到聊天服务器。
发送消息的状态,可以通过设置 EMMessage#setMessageStatusCallback(EMCallBack) 进行监听。
msg | 待发送消息对象,不能为空。 |
void com.hyphenate.chat.EMChatManager.setMessageListened | ( | EMMessage | message | ) |
void com.hyphenate.chat.EMChatManager.setVoiceMessageListened | ( | EMMessage | message | ) |
将消息设置为已听。 一般用于语音消息。
message | 要设置的消息对象。 |
void com.hyphenate.chat.EMChatManager.translateMessage | ( | EMMessage | message, |
List< String > | languages, | ||
EMValueCallBack< EMMessage > | callBack | ||
) |
翻译消息
message | 消息对象 |
languages | 要翻译的目标语言code列表 |
callBack | 完成回调 |
boolean com.hyphenate.chat.EMChatManager.updateMessage | ( | EMMessage | message | ) |
更新本地消息。
会更新本地内存和数据库。
message | 要更新的消息对象。 |
boolean com.hyphenate.chat.EMChatManager.updateParticipant | ( | String | from, |
String | changeTo | ||
) |
将数据库中的某个联系人相关信息变更成另外一个联系人。
与变更相关的表单包含消息表单,会话表单,联系人表单,黑名单表单。
注意:该操作不会更新内存中数据。
from | 更换前的用户 ID。 |
changeTo | 更换后的用户 ID。 |
false
。