hyphenate_SDK3.0  3.5.0
hyphenatejavaIMSDK
Classes | Public Member Functions | Static Public Member Functions | List of all members
com.hyphenate.chat.EMConversation Class Reference
Inheritance diagram for com.hyphenate.chat.EMConversation:
Inheritance graph
[legend]
Collaboration diagram for com.hyphenate.chat.EMConversation:
Collaboration graph
[legend]

Classes

enum  EMConversationType
 
enum  EMSearchDirection
 
class  MessageCache
 

Public Member Functions

String conversationId ()
 
EMConversationType getType ()
 
int getUnreadMsgCount ()
 
void markAllMessagesAsRead ()
 
int getAllMsgCount ()
 
List< EMMessageloadMoreMsgFromDB (String startMsgId, int pageSize)
 
List< EMMessagesearchMsgFromDB (long timeStamp, int maxCount, EMSearchDirection direction)
 
List< EMMessagesearchMsgFromDB (EMMessage.Type type, long timeStamp, int maxCount, String from, EMSearchDirection direction)
 
List< EMMessagesearchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, EMSearchDirection direction)
 
List< EMMessagesearchMsgFromDB (long startTimeStamp, long endTimeStamp, int maxCount)
 
EMMessage getMessage (String messageId, boolean markAsRead)
 
List< EMMessageloadMessages (List< String > msgIds)
 
void markMessageAsRead (String messageId)
 
List< EMMessagegetAllMessages ()
 
void removeMessage (String messageId)
 
EMMessage getLastMessage ()
 
EMMessage getLatestMessageFromOthers ()
 
void clear ()
 
void clearAllMessages ()
 
void setExtField (String ext)
 
String getExtField ()
 
boolean isGroup ()
 
void insertMessage (EMMessage msg)
 
void appendMessage (EMMessage msg)
 
boolean updateMessage (EMMessage msg)
 
String getMessageAttachmentPath ()
 
- Public Member Functions inherited from com.hyphenate.chat.EMBase< EMAConversation >
boolean equals (Object o)
 
int hashCode ()
 

Static Public Member Functions

static EMConversationType msgType2ConversationType (String id, EMMessage.ChatType type)
 

Additional Inherited Members

- Protected Attributes inherited from com.hyphenate.chat.EMBase< EMAConversation >
emaObject
 

Detailed Description

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();

Version
3.0

Member Function Documentation

void 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.

Parameters
msgMessage
void com.hyphenate.chat.EMConversation.clear ( )

clear messages in this conversation's from cache, but will NOT clear local database

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 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 local cache, if empty, then get from local database.

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.

Returns
extension object
EMMessage com.hyphenate.chat.EMConversation.getLastMessage ( )

get last message from conversation

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.

Parameters
messageId
markAsReadif true, will mark the message as read and send read ack to server
Returns
message
String com.hyphenate.chat.EMConversation.getMessageAttachmentPath ( )

return conversation associated attachment path, can be used to erase conversation related downloaded files from local storage. not ensure the return path exists, please handle IOException when deleting directory

Returns
EMConversationType com.hyphenate.chat.EMConversation.getType ( )

get conversation type

int com.hyphenate.chat.EMConversation.getUnreadMsgCount ( )

get unread message count

void 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. The inserting message will be inserted based on timestamp.

Parameters
msgMessage
boolean com.hyphenate.chat.EMConversation.isGroup ( )

group chat and chatroom chat will both return true

Returns
group chat and chatroom chat will both return true, otherwise return false.
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.

Parameters
msgIdsmessages to be loaded.
Returns
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

Parameters
startMsgIdmessage storage time will before this ID, if startMsgId is "" or null, will load last messages in database.
pageSizemessage count to be loaded.
Returns
messages
void com.hyphenate.chat.EMConversation.markAllMessagesAsRead ( )

Mark all messages as read

void com.hyphenate.chat.EMConversation.markMessageAsRead ( String  messageId)

mark the message as read, and send read as to server.

Parameters
messageIdmessageID
static EMConversationType com.hyphenate.chat.EMConversation.msgType2ConversationType ( String  id,
EMMessage.ChatType  type 
)
static

provide transformation from message type to conversation type

Parameters
idmessage Id, used to distinguish single chat and help desk, has no effect on other chat type.
typemessage type
Returns
conversation type
void com.hyphenate.chat.EMConversation.removeMessage ( String  messageId)

delete a message

Parameters
messageIdmessage to be deleted
List<EMMessage> com.hyphenate.chat.EMConversation.searchMsgFromDB ( long  timeStamp,
int  maxCount,
EMSearchDirection  direction 
)

search message from database according the parameter Note: Cautious about memory usage when the maxCount is large

Parameters
timeStampthe timestamp for search
maxCountthe max number of message to search
Returns
the list of searched messages
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: Cautious about memory usage when the maxCount is large

Parameters
typemessage type, TXT、VOICE、IMAGE etc.
timeStampthe timestamp for search
maxCountthe max number of message to search
fromwho the message from, used to search in group
Returns
the list of searched messages
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

Parameters
keywordsthe keywords in message.
timeStampthe timestamp for search
maxCountthe max number of message to search
fromwho the message from, used to search in group
Returns
the list of searched messages
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

Parameters
startTimeStampstart timestamp for search in.
startTimeStampend timestamp for search
maxCountthe max number of message to search
Returns
the list of searched messages
void com.hyphenate.chat.EMConversation.setExtField ( String  ext)

set Conversation extension. extend field only stored in local database, not sync to network server.

Parameters
extextension string
boolean com.hyphenate.chat.EMConversation.updateMessage ( EMMessage  msg)

Update a message in local database. latestMessage of the conversation and other properties will be updated accordingly. messageId of the message cannot be updated

Parameters
msgMessage

The documentation for this class was generated from the following file: