类 | |
| enum | EMConversationType |
| enum | EMMarkType |
| enum | EMMessageSearchScope |
| enum | EMSearchDirection |
Public 成员函数 | |
| Set< EMMarkType > | marks () |
| String | conversationId () |
| EMConversationType | getType () |
| int | getUnreadMsgCount () |
| void | markAllMessagesAsRead () |
| int | getAllMsgCount () |
| int | getAllMsgCount (long startTimestamp, long endTimestamp) |
| boolean | isChatThread () |
| List< EMMessage > | loadMoreMsgFromDB (String startMsgId, int pageSize) |
| List< EMMessage > | loadMoreMsgFromDB (String startMsgId, int pageSize, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (long timeStamp, int maxCount, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (Type type, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (Set< Type > types, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMSearchDirection direction, EMMessageSearchScope searchScope) |
| void | asyncSearchMsgFromDB (String keywords, long timeStamp, int maxCount, List< String > senders, EMSearchDirection direction, EMMessageSearchScope searchScope, EMValueCallBack< List< EMMessage > > callback) |
| List< EMMessage > | searchMsgFromDB (long startTimeStamp, long endTimeStamp, int maxCount) |
| List< EMMessage > | searchCustomMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
| EMMessage | getMessage (String messageId, boolean markAsRead) |
| void | markMessageAsRead (String messageId) |
| List< EMMessage > | getAllMessages () |
| void | removeMessage (String messageId) |
| EMMessage | getLastMessage () |
| EMMessage | getLatestMessageFromOthers () |
| void | clear () |
| void | clearAllMessages () |
| void | setExtField (String ext) |
| String | getExtField () |
| boolean | isPinned () |
| long | getPinnedTime () |
| boolean | isGroup () |
| boolean | insertMessage (EMMessage msg) |
| boolean | appendMessage (EMMessage msg) |
| boolean | updateMessage (EMMessage msg) |
| String | getMessageAttachmentPath () |
| void | removeMessagesFromServer (List< String > msgIdList, EMCallBack callBack) |
| void | removeMessagesFromServer (long beforeTimeStamp, EMCallBack callBack) |
| boolean | removeMessages (long startTime, long endTime) |
| List< EMMessage > | pinnedMessages () |
| EMPushManager.EMPushRemindType | pushRemindType () |
静态 Public 成员函数 | |
| static EMConversationType | msgType2ConversationType (String id, EMMessage.ChatType type) |
会话类,用于定义单聊会话、群聊会话和聊天室会话。
每类会话中包含发送和接收的消息。
例如,从会话中获取未读消息数:
| boolean com.hyphenate.chat.EMConversation.appendMessage | ( | EMMessage | msg | ) |
在本地数据库中会话的尾部插入一条消息。
消息的会话 ID 应与会话的 ID 一致。
消息插入后,SDK 会自动更新会话的 latestMessage 等属性。
| msg | 消息实例。 |
| void com.hyphenate.chat.EMConversation.asyncSearchMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| List< String > | senders, | ||
| EMSearchDirection | direction, | ||
| EMMessageSearchScope | searchScope, | ||
| EMValueCallBack< List< EMMessage > > | callback ) |
从本地数据库获取会话中的指定用户发送的包含特定关键词的消息。
| keywords | 查询的关键字。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。如果设为小于等于 0,SDK 会获取一条消息。 |
| senders | 消息发送方的用户 ID 列表, 长度小于10。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息,对消息发送方不限制。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| searchScope | 消息搜索范围。详见 EMMessageSearchScope。 |
| void com.hyphenate.chat.EMConversation.clear | ( | ) |
清除会话中的所有消息。
只清除内存的,不清除本地数据库的消息。
在退出会话的时候清除内存缓存,减小内存消耗。
| void com.hyphenate.chat.EMConversation.clearAllMessages | ( | ) |
清除内存和数据库中指定会话中的消息。
| String com.hyphenate.chat.EMConversation.conversationId | ( | ) |
会话 ID,取决于会话类型。
| List< EMMessage > com.hyphenate.chat.EMConversation.getAllMessages | ( | ) |
获取该会话当前内存中的所有消息。
如果内存中为空,SDK 再从本地数据库中加载最近一条消息。
| int com.hyphenate.chat.EMConversation.getAllMsgCount | ( | ) |
获取 SDK 本地数据库中会话的全部消息数。
| int com.hyphenate.chat.EMConversation.getAllMsgCount | ( | long | startTimestamp, |
| long | endTimestamp ) |
获取 SDK 本地数据库中会话某个时间段内的全部消息数。
| startTimestamp | 起始时间戳(包含),单位为毫秒。 |
| endTimestamp | 结束时间戳(包含),单位为毫秒。 |
| String com.hyphenate.chat.EMConversation.getExtField | ( | ) |
获取会话的扩展字段。
扩展字段只在本地数据库中保存,不同步到服务器。
子区会话的扩展字段不在本地数据库中保存。
| EMMessage com.hyphenate.chat.EMConversation.getLastMessage | ( | ) |
获取会话中的最新一条消息。
此操作不会改变未读消息计数。
SDK 首先在内存中查找消息,若在内存中未找到,SDK 会在本地数据库查询并加载。
| EMMessage com.hyphenate.chat.EMConversation.getLatestMessageFromOthers | ( | ) |
获取会话中收到的最新一条消息。
| EMMessage com.hyphenate.chat.EMConversation.getMessage | ( | String | messageId, |
| boolean | markAsRead ) |
根据消息 ID 获取已读的消息。
SDK 首先在内存中查找消息,若在内存中未找到,SDK 会在本地数据库查询并加载。
| messageId | 消息 ID。 |
| markAsRead | 是否将获取的消息标为已读。
|
| String com.hyphenate.chat.EMConversation.getMessageAttachmentPath | ( | ) |
获取会话对应的附件的存储路径。
该方法适用于清理会话数据前,如果不确定该路径一定存在,请调用该方法前查询路径。如有必要,添加异常保护。
| long com.hyphenate.chat.EMConversation.getPinnedTime | ( | ) |
获取会话置顶时间。
0。 | EMConversationType com.hyphenate.chat.EMConversation.getType | ( | ) |
获取会话类型。
| int com.hyphenate.chat.EMConversation.getUnreadMsgCount | ( | ) |
获取会话中未读的消息数量。
| boolean com.hyphenate.chat.EMConversation.insertMessage | ( | EMMessage | msg | ) |
在本地数据库的会话中插入一条消息。
消息的会话 ID 应与会话的 ID 一致。
消息会根据消息里的 Unix 时间戳插入本地数据库,SDK 会更新会话的 latestMessage 等属性。
| msg | 消息实例。 |
| boolean com.hyphenate.chat.EMConversation.isChatThread | ( | ) |
查看当前会话是否是子区会话。
true 表示是子区会话。false 表示不是子区会话。 | boolean com.hyphenate.chat.EMConversation.isGroup | ( | ) |
获取是否是群组或者聊天室会话。
true,其他类型返回 false。 | boolean com.hyphenate.chat.EMConversation.isPinned | ( | ) |
获取会话的置顶状态。
true:会话处于置顶状态。false:会话处于非置顶状态。 | List< EMMessage > com.hyphenate.chat.EMConversation.loadMoreMsgFromDB | ( | String | startMsgId, |
| int | pageSize ) |
从 SDK 本地数据库中分页加载消息。
加载的消息会基于消息中的时间戳放入当前会话的缓存中,调用 getAllMessages() 时会返回所有加载的消息。
| startMsgId | 查询的起始消息 ID。SDK 从该消息 ID 开始按消息时间戳的逆序加载。如果传入消息的 ID 为空,SDK 从最新消息开始按消息时间戳的逆序获取。 |
| pageSize | 每页期望加载的消息数。取值范围为 [1,400]。 |
| List< EMMessage > com.hyphenate.chat.EMConversation.loadMoreMsgFromDB | ( | String | startMsgId, |
| int | pageSize, | ||
| EMSearchDirection | direction ) |
从指定消息 ID 开始分页加载数据库中的消息。
加载到的消息会加入到当前会话的消息中。
| startMsgId | 查询的起始消息 ID。该参数设置后,SDK 从指定的消息 ID 开始按消息检索方向加载。 如果传入消息的 ID 为空,SDK 忽略该参数,按搜索方向查询消息:
|
| pageSize | 每页期望加载的消息数。取值范围为 [1,40]。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| void com.hyphenate.chat.EMConversation.markAllMessagesAsRead | ( | ) |
将所有未读消息设置为已读。
| void com.hyphenate.chat.EMConversation.markMessageAsRead | ( | String | messageId | ) |
| Set< EMMarkType > com.hyphenate.chat.EMConversation.marks | ( | ) |
获取会话的所有标记。
|
static |
将消息类型转化为会话类型。
| id | 消息 ID。 |
| type | 消息类型。 |
| List< EMMessage > com.hyphenate.chat.EMConversation.pinnedMessages | ( | ) |
从本地获取会话中所有置顶的消息。
| EMPushManager.EMPushRemindType com.hyphenate.chat.EMConversation.pushRemindType | ( | ) |
从本地获取会话的推送提醒类型。如果本地没有则默认返回EMPushManager.EMPushRemindType#ALL。
| void com.hyphenate.chat.EMConversation.removeMessage | ( | String | messageId | ) |
删除本地数据库中的一条指定消息。
| messageId | 待删除消息的 ID。 |
| boolean com.hyphenate.chat.EMConversation.removeMessages | ( | long | startTime, |
| long | endTime ) |
从本地数据库中删除指定时间段内的消息。
| startTime | 删除消息的起始时间。Unix 时间戳,单位为毫秒。 |
| endTime | 删除消息的结束时间。Unix 时间戳,单位为毫秒。 |
true。false。 | void com.hyphenate.chat.EMConversation.removeMessagesFromServer | ( | List< String > | msgIdList, |
| EMCallBack | callBack ) |
单向删除漫游消息(根据消息 ID 删除)。
| msgIdList | 要从服务器单向删除的消息 ID 列表。 |
| callBack | 处理结果回调,详见 EMCallBack。 |
| void com.hyphenate.chat.EMConversation.removeMessagesFromServer | ( | long | beforeTimeStamp, |
| EMCallBack | callBack ) |
单向删除漫游消息(根据时间删除)。
| beforeTimeStamp | 消息删除开始的 UNIX 时间戳,单位为毫秒。设置开始时间后,该方法删除服务器在该时间点之前接收到的消息。 |
| callBack | 处理结果回调,详见 EMCallBack。 |
| List< EMMessage > com.hyphenate.chat.EMConversation.searchCustomMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction ) |
从本地数据库获取会话中的指定用户发送的包含特定关键词的自定义消息。
| keywords | 搜索的关键词。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息,对发送方不限制。 |
| direction | 消息加载方向。详见 EMSearchDirection。 |
| List< EMMessage > com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | startTimeStamp, |
| long | endTimeStamp, | ||
| int | maxCount ) |
从本地数据库中搜索指定时间段内发送或接收的一定数量的消息。
| startTimeStamp | 搜索的起始时间戳。单位为毫秒。详见 EMOptions#setSortMessageByServerTime。 |
| endTimeStamp | 搜索的结束时间戳。单位为毫秒。详见 EMOptions#setSortMessageByServerTime。 |
| maxCount | 每次获取的最大消息数量。取值范围为 [1,400]。 |
| List< EMMessage > com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | timeStamp, |
| int | maxCount, | ||
| EMSearchDirection | direction ) |
基于 Unix 时间戳搜索本地数据库中的消息。
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从最新消息获取。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| List< EMMessage > com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | Set< Type > | types, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction ) |
从本地数据库获取指定会话的一定数量的多种类型的消息。
| types | 消息类型。详见 Type。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息,对消息发送方不限制。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| List< EMMessage > com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction ) |
从本地数据库获取会话中的指定用户发送的包含特定关键词的消息。
| keywords | 查询的关键字。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息,对消息发送方不限制。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| List< EMMessage > com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction, | ||
| EMMessageSearchScope | searchScope ) |
从本地数据库获取会话中的指定用户发送的包含特定关键词的消息。
| keywords | 查询的关键字。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 如果该参数设置为负数,SDK 从当前时间开始搜索。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。如果设为小于等于 0,SDK 会获取一条消息。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息,对消息发送方不限制。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| searchScope | 消息搜索范围。详见 EMMessageSearchScope。 |
| List< EMMessage > com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | Type | type, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction ) |
从本地数据库获取指定会话的一定数量的特定类型的消息。
| type | 消息类型。详见 Type。 |
| timeStamp | 查询的起始消息 Unix 时间戳,单位为毫秒。该参数设置后,SDK 从指定时间戳的消息开始,按消息搜索方向获取。 |
| maxCount | 每次获取的最大消息数。取值范围为 [1,400]。 |
| from | 消息发送方的用户 ID。若设置为 null 或空字符串,SDK 将在整个会话中搜索消息,对消息发送方不限制。 |
| direction | 消息搜索方向。详见 EMSearchDirection。
|
| void com.hyphenate.chat.EMConversation.setExtField | ( | String | ext | ) |
设置会话的扩展字段。
扩展字段只在本地数据库中保存,不同步到服务器。
子区会话的扩展字段不在本地数据库中保存。
| ext | 会话的扩展字段。 |
| boolean com.hyphenate.chat.EMConversation.updateMessage | ( | EMMessage | msg | ) |
更新本地数据库的指定消息。
消息更新时,消息 ID 不会修改。
消息更新后,SDK 会自动更新会话的 latestMessage 等属性。
| msg | 要更新的消息。 |