|
hyphenate_SDK3.0
3.1.4
hyphenatejavaIMSDK
|
类 | |
| enum | EMConversationType |
| enum | EMSearchDirection |
| class | MessageCache |
Public 成员函数 | |
| String | conversationId () |
| EMConversationType | getType () |
| int | getUnreadMsgCount () |
| void | markAllMessagesAsRead () |
| int | getAllMsgCount () |
| List< EMMessage > | loadMoreMsgFromDB (String startMsgId, int pageSize) |
| List< EMMessage > | searchMsgFromDB (long timeStamp, int maxCount, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (EMMessage.Type type, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
| List< EMMessage > | searchMsgFromDB (long startTimeStamp, long endTimeStamp, int maxCount) |
| EMMessage | getMessage (String messageId, boolean markAsRead) |
| List< EMMessage > | loadMessages (List< String > msgIds) |
| void | markMessageAsRead (String messageId) |
| List< EMMessage > | getAllMessages () |
| int | getMessagePosition (EMMessage message) |
| String | getUserName () |
| void | removeMessage (String messageId) |
| EMMessage | getLastMessage () |
| void | clear () |
| void | clearAllMessages () |
| void | setExtField (String ext) |
| String | getExtField () |
| boolean | isGroup () |
| void | insertMessage (EMMessage msg) |
| void | appendMessage (EMMessage msg) |
| boolean | updateMessage (EMMessage msg) |
静态 Public 成员函数 | |
| static EMConversationType | msgType2ConversationType (String id, EMMessage.ChatType type) |
EMConversation 代表和一个用户的对话,包含发送和接收的消息
下面的示例会取得对话中未读的消息数:
EMConversation conversation = EMChatManager.getInstance().getConversation("user1"); int unread = conversation.getUnreadMsgCount();
| void com.hyphenate.chat.EMConversation.appendMessage | ( | EMMessage | msg | ) |
向数据库和缓存中添加消息,消息会添加到队列的尾部
| void com.hyphenate.chat.EMConversation.clear | ( | ) |
清除对话中的所有消息,只清除内存的,不清除db的消息
| void com.hyphenate.chat.EMConversation.clearAllMessages | ( | ) |
清除对话中的所有消息,同时清除内存和数据库中的消息
| String com.hyphenate.chat.EMConversation.conversationId | ( | ) |
会话ID
对于单聊类型,会话ID同时也是对方用户的名称。
对于群聊类型,会话ID同时也是对方群组的ID,并不同于群组的名称。
对于聊天室类型,会话ID同时也是聊天室的ID,并不同于聊天室的名称。
对于HelpDesk类型,会话ID与单聊类型相同,是对方用户的名称。
| List<EMMessage> com.hyphenate.chat.EMConversation.getAllMessages | ( | ) |
获取此conversation当前内存所有的message
| int com.hyphenate.chat.EMConversation.getAllMsgCount | ( | ) |
获取本地存储会话的全部消息数目
| String com.hyphenate.chat.EMConversation.getExtField | ( | ) |
获取用户可以自行定义会话扩展字段 该字段只保存在本地,不进行网络同步
| EMMessage com.hyphenate.chat.EMConversation.getLastMessage | ( | ) |
获取队列中的最后一条消息 (此操作不会改变未读消息计数)
| EMMessage com.hyphenate.chat.EMConversation.getMessage | ( | String | messageId, |
| boolean | markAsRead | ||
| ) |
根据msgid获取消息
| messageId | 需要获取的消息id |
| markAsRead | 是否获取消息的同时标记消息为已读 |
| int com.hyphenate.chat.EMConversation.getMessagePosition | ( | EMMessage | message | ) |
获取message的position
| message |
| EMConversationType com.hyphenate.chat.EMConversation.getType | ( | ) |
获取会话类型
| int com.hyphenate.chat.EMConversation.getUnreadMsgCount | ( | ) |
获取此对话中未读取的消息数目
| String com.hyphenate.chat.EMConversation.getUserName | ( | ) |
获取此对话的用户id 或群组id
| void com.hyphenate.chat.EMConversation.insertMessage | ( | EMMessage | msg | ) |
向数据库和缓存中插入消息
| boolean com.hyphenate.chat.EMConversation.isGroup | ( | ) |
群组和聊天室类型都会返回true
| List<EMMessage> com.hyphenate.chat.EMConversation.loadMessages | ( | List< String > | msgIds | ) |
加载一组消息,如果缓存不存在会去DB查询并加载
| msgIds | 一组消息ID |
| List<EMMessage> com.hyphenate.chat.EMConversation.loadMoreMsgFromDB | ( | String | startMsgId, |
| int | pageSize | ||
| ) |
根据传入的参数从db加载startMsgId之前(存储顺序)指定数量的message, 加载到的messages会加入到当前conversation的messages里
| startMsgId | 加载这个id之前的message |
| pageSize | 加载多少条 |
| void com.hyphenate.chat.EMConversation.markMessageAsRead | ( | String | messageId | ) |
设置某条消息为已读
| messageId | 消息ID |
|
static |
从消息类型到会话类型的转化
| id | 消息Id,用来区分客服和单聊,对于其他类型,这个参数没有影响。 |
| 消息类型 |
| void com.hyphenate.chat.EMConversation.removeMessage | ( | String | messageId | ) |
删除一条指定的消息
| messageId | 待删除消息的ID |
| List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | timeStamp, |
| int | maxCount, | ||
| EMSearchDirection | direction | ||
| ) |
根据传入的参数从本地存储中搜索指定数量的message。 注意:当maxCount非常大时,需要考虑内存消耗
| timeStamp | 搜索消息的时间点 |
| maxCount | 搜索结果的最大条数 |
| List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | EMMessage.Type | type, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction | ||
| ) |
根据传入的参数从本地存储中搜索指定数量的message。 注意:当maxCount非常大时,需要考虑内存消耗
| type | 消息类型,文本、图片、语音等等 |
| timeStamp | 搜索消息的时间点 |
| maxCount | 搜索结果的最大条数 |
| from | 搜索来自某人的消息,适用于搜索群组里的消息 |
| List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | String | keywords, |
| long | timeStamp, | ||
| int | maxCount, | ||
| String | from, | ||
| EMSearchDirection | direction | ||
| ) |
根据传入的参数从本地存储中搜索指定数量的message。 注意:当maxCount非常大时,需要考虑内存消耗
| keywords | 搜索消息中的关键词 |
| timeStamp | 搜索消息的时间点 |
| maxCount | 搜索结果的最大条数 |
| from | 搜索来自某人的消息,适用于搜索群组里的消息 |
| List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | startTimeStamp, |
| long | endTimeStamp, | ||
| int | maxCount | ||
| ) |
根据传入的参数从本地存储中搜索指定数量的message。 注意:当maxCount非常大时,需要考虑内存消耗
| startTimeStamp | 搜索的起始时间 |
| endTimeStamp | 搜索的结束时间 |
| maxCount | 搜索结果的最大条数 |
| void com.hyphenate.chat.EMConversation.setExtField | ( | String | ext | ) |
用户可以自行定义会话扩展字段 该字段只保存在本地,不进行网络同步
| value | 会话对应扩展字段的内容 |
| boolean com.hyphenate.chat.EMConversation.updateMessage | ( | EMMessage | msg | ) |
更新本地的消息
1.8.9.1