hyphenate_SDK3.0
3.8.5
hyphenatejavaIMSDK
|
Inherits com.hyphenate.chat.EMBase< T >.
Classes | |
enum | EMConversationType |
enum | EMSearchDirection |
class | MessageCache |
Public Member Functions | |
String | conversationId () |
EMConversationType | getType () |
int | getUnreadMsgCount () |
void | markAllMessagesAsRead () |
int | getAllMsgCount () |
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 (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) |
List< EMMessage > | searchCustomMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMSearchDirection direction) |
EMMessage | getMessage (String messageId, boolean markAsRead) |
List< EMMessage > | loadMessages (List< String > msgIds) |
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 | isGroup () |
boolean | insertMessage (EMMessage msg) |
boolean | appendMessage (EMMessage msg) |
boolean | updateMessage (EMMessage msg) |
String | getMessageAttachmentPath () |
Static Public Member Functions | |
static EMConversationType | msgType2ConversationType (String id, EMMessage.ChatType type) |
Conversation class, represent a conversation with a user/group/chat room and contains messages that are sent and received For example, Gets the number of unread messages from the conversation:
// ConversationId can be the other party id, the group id, or the chat room id EMConversation conversation = EMClient.getInstance().chatManager().getConversation(conversationId); int unread = conversation.getUnreadMsgCount();
boolean com.hyphenate.chat.EMConversation.appendMessage | ( | EMMessage | msg | ) |
Insert a message to the end of a conversation in local database ConversationId of the message should be the same as conversationId of the conversation in order to insert the message into the conversation correctly. And the latestMessage and other properties of the session should be updated
msg | Message |
void com.hyphenate.chat.EMConversation.clear | ( | ) |
Clear messages in this conversation Which clear only memory messages, but will not clear local database Reduce memory consumption by clearing the memory cache when exiting a conversation
void com.hyphenate.chat.EMConversation.clearAllMessages | ( | ) |
Delete all messages of the conversation from memory cache and local database
String com.hyphenate.chat.EMConversation.conversationId | ( | ) |
Conversation ID For single chat,conversation ID is to chat user's name For group chat, conversation ID is group ID, different with group name For chat room, conversation ID is chatroom ID, different with chat room name For help desk, it is same with single chat, conversationID is also chat user's name
List<EMMessage> com.hyphenate.chat.EMConversation.getAllMessages | ( | ) |
Get all message in local cache If empty, then get latest message from local database
int com.hyphenate.chat.EMConversation.getAllMsgCount | ( | ) |
Get all messages count in this conversation
String com.hyphenate.chat.EMConversation.getExtField | ( | ) |
Get conversation extension Extend field only stored in local database, not sync to network server
EMMessage com.hyphenate.chat.EMConversation.getLastMessage | ( | ) |
Get last message from conversation The operation does not change the unread message count Get from cache, if empty, will load from database and put it in the cache
EMMessage com.hyphenate.chat.EMConversation.getLatestMessageFromOthers | ( | ) |
Get received latest message from conversation
EMMessage com.hyphenate.chat.EMConversation.getMessage | ( | String | messageId, |
boolean | markAsRead | ||
) |
Get message by message ID, If the message already loaded into memory cache, will directly return the message, otherwise load message from database, and put it into cache
messageId | Message id |
markAsRead | Whether to mark the message as read while getting it, if true, will mark the message as read and send read ack to server |
String com.hyphenate.chat.EMConversation.getMessageAttachmentPath | ( | ) |
Return conversation associated attachment path Which can be used to erase conversation related downloaded files from local storage. Not ensure the return path exists, please handle IOException when deleting directory
EMConversationType com.hyphenate.chat.EMConversation.getType | ( | ) |
Get conversation type
int com.hyphenate.chat.EMConversation.getUnreadMsgCount | ( | ) |
Get unread message count
boolean com.hyphenate.chat.EMConversation.insertMessage | ( | EMMessage | msg | ) |
Insert a message to a conversation in local database ConversationId of the message should be the same as conversationId of the conversation in order to insert the message into the conversation correctly. And the latestMessage and other properties of the session should be updated
msg | Instance of Message |
boolean com.hyphenate.chat.EMConversation.isGroup | ( | ) |
Gets whether it is a group or chat room conversation
List<EMMessage> com.hyphenate.chat.EMConversation.loadMessages | ( | List< String > | msgIds | ) |
Load messages, If those message not exists in memory in cache, will load message from database
msgIds | message ids to be loaded |
List<EMMessage> com.hyphenate.chat.EMConversation.loadMoreMsgFromDB | ( | String | startMsgId, |
int | pageSize | ||
) |
Load more messages from database Load message from database by passing in parameters, which message id starting from param startMsgId, messages will also store in to current conversation's memory cache, so next time calling getAllMessages(), result will contain those messages
startMsgId | message storage time will before this ID, if startMsgId is "" or null, will load last messages in database |
pageSize | message count to be loaded |
List<EMMessage> com.hyphenate.chat.EMConversation.loadMoreMsgFromDB | ( | String | startMsgId, |
int | pageSize, | ||
EMSearchDirection | direction | ||
) |
load message from database, message id starting from param startMsgId, messages will also store in to memory cache so next time calling getAllMessages(), result will contain those messages
startMsgId | message storage time will before this ID, if startMsgId is "" or null, will load last messages in database. |
pageSize | message count to be loaded. |
direction | direction in which the message is loaded |
void com.hyphenate.chat.EMConversation.markAllMessagesAsRead | ( | ) |
Mark all messages as read
void com.hyphenate.chat.EMConversation.markMessageAsRead | ( | String | messageId | ) |
Mark the message as read by specified messageId To make the message read, you can also use EMMessage#setUnread(boolean)
messageId | Message id |
|
static |
Provide transformation from message type to conversation type
id | Message Id, used to distinguish single chat and help desk, has no effect on other chat type |
type | Message type |
void com.hyphenate.chat.EMConversation.removeMessage | ( | String | messageId | ) |
Delete a message Note: Operates only on local data
messageId | message to be deleted |
List<EMMessage> com.hyphenate.chat.EMConversation.searchCustomMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
EMSearchDirection | direction | ||
) |
Search custom messages from database based the parameters Note: Cautious about memory usage when the maxCount is large
keywords | The keywords in message. |
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
from | Who the message from, also can used to search in group |
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | timeStamp, |
int | maxCount, | ||
EMSearchDirection | direction | ||
) |
Search message from database according the parameters Note: Cautious about memory usage when the maxCount is large
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | EMMessage.Type | type, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
EMSearchDirection | direction | ||
) |
Search message from database according the parameters Note: Cautious about memory usage when the maxCount is large
type | Message type, TXT、VOICE、IMAGE and so on |
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
from | Who the message from, also can used to search in group |
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
EMSearchDirection | direction | ||
) |
Search message from database based the parameters Note: Cautious about memory usage when the maxCount is large
keywords | The keywords in message. |
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
from | Who the message from, also can used to search in group |
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | startTimeStamp, |
long | endTimeStamp, | ||
int | maxCount | ||
) |
Search message from database based the parameters Note: Cautious about memory usage when the maxCount is large
startTimeStamp | Start timestamp for search in |
endTimeStamp | End timestamp for search |
maxCount | The max number of message to search |
void com.hyphenate.chat.EMConversation.setExtField | ( | String | ext | ) |
Set Conversation extension Extend field only stored in local database, not sync to network server
ext | Extension string |
boolean com.hyphenate.chat.EMConversation.updateMessage | ( | EMMessage | msg | ) |
Update a message in local database Message id of the message cannot be updated. Latest Message of the conversation and other properties will be updated accordingly.
msg | Message |