hyphenate_SDK3.0
3.0.1
hyphenatejavaIMSDK
|
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 > | 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) |
Static Public Member Functions | |
static EMConversationType | msgType2ConversationType (String id, EMMessage.ChatType type) |
EMConversation represent a conversation chating with a user, containing chat messages.
Example illustrate how to get unread message count
EMConversation conversation = EMClient.getInstance().chatManager().getConversation("user1"); int unread = conversation.getUnreadMsgCount();
void com.hyphenate.chat.EMConversation.clear | ( | ) |
clear messages in this conversation's memory cache, but not clear database's message.
void com.hyphenate.chat.EMConversation.clearAllMessages | ( | ) |
clear messages in this conversation's memory cache, also clear this conversation's message under 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 groupID(), different with getGroupName()
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 memory cache
int com.hyphenate.chat.EMConversation.getAllMsgCount | ( | ) |
get all messages count in this conversation
String com.hyphenate.chat.EMConversation.getExtField | ( | ) |
get conversation's extend field, extend field only stored in local database, not sync to network server.
EMMessage com.hyphenate.chat.EMConversation.getLastMessage | ( | ) |
get last message from conversation, this function will not mark the message as read
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 memory cache.
messageId | |
markAsRead | if set to be true, will mark the message as read, and send read ack to server |
int com.hyphenate.chat.EMConversation.getMessagePosition | ( | EMMessage | message | ) |
get the message position in memory cache
message |
EMConversationType com.hyphenate.chat.EMConversation.getType | ( | ) |
get conversation type
int com.hyphenate.chat.EMConversation.getUnreadMsgCount | ( | ) |
get unread message count
String com.hyphenate.chat.EMConversation.getUserName | ( | ) |
get the conversation ID, for single chat, it is user name, for group and chatroom, it is groupID or chatroomID, which different from group name or chatroom name.
void com.hyphenate.chat.EMConversation.insertMessage | ( | EMMessage | msg | ) |
insert mesasge into cache and local database
boolean com.hyphenate.chat.EMConversation.isGroup | ( | ) |
group chat and chatroom chat will both return true
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 | messages to be loaded. |
List<EMMessage> com.hyphenate.chat.EMConversation.loadMoreMsgFromDB | ( | String | startMsgId, |
int | pageSize | ||
) |
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. |
void com.hyphenate.chat.EMConversation.markMessageAsRead | ( | String | messageId | ) |
mark the message as read, and send read as to server.
|
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. |
message | type |
void com.hyphenate.chat.EMConversation.removeMessage | ( | String | messageId | ) |
delete a message
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | timeStamp, |
int | maxCount, | ||
EMSearchDirection | direction | ||
) |
search message from database according the parameter Note: please consider your memory when the maxCount is huge
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 parameter Note: please consider your memory when the maxCount is huge
type | message type, TXT、VOICE、IMAGE etc. |
timeStamp | the timestamp for search |
maxCount | the max number of message to search |
from | who the message from, 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 according the parameter Note: please consider your memory when the maxCount is huge
keywords | the keywords in message. |
timeStamp | the timestamp for search |
maxCount | the max number of message to search |
from | who the message from, used to search in group |
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB | ( | long | startTimeStamp, |
long | endTimeStamp, | ||
int | maxCount | ||
) |
search message from database according the parameter Note: please consider your memory when the maxCount is huge
startTimeStamp | start timestamp for search in. |
startTimeStamp | end timestamp for search |
maxCount | the max number of message to search |
void com.hyphenate.chat.EMConversation.setExtField | ( | String | ext | ) |
set conversation's extend field, extend field only stored in local database, not sync to network server.