hyphenate_SDK3.0  3.0.1
hyphenatejavaIMSDK
Public Member Functions | Protected Member Functions | List of all members
com.hyphenate.chat.EMChatManager Class Reference

Public Member Functions

void sendMessage (final EMMessage msg)
 
void ackMessageRead (String to, String messageId) throws HyphenateException
 
EMMessage getMessage (String messageId)
 
EMConversation getConversation (String id)
 
EMConversation getConversation (String id, EMConversationType type)
 
EMConversation getConversation (String username, EMConversationType type, boolean createIfNotExists)
 
void markAllConversationsAsRead ()
 
int getUnreadMsgsCount ()
 
void saveMessage (EMMessage message)
 
boolean updateMessage (EMMessage message)
 
void downloadAttachment (final EMMessage msg)
 
void downloadThumbnail (final EMMessage msg)
 
synchronized void importMessages (List< EMMessage > msgs)
 
List< EMConversationgetConversationsByType (EMConversation.EMConversationType type)
 
boolean isSlientMessage (EMMessage message)
 
void downloadFile (final String remoteUrl, final String localFilePath, final Map< String, String > headers, final EMCallBack callback)
 
Map< String, EMConversationgetAllConversations ()
 
void loadAllConversations ()
 
boolean deleteConversation (String username, boolean deleteMessages)
 
void addMessageListener (EMMessageListener listener)
 
void removeMessageListener (EMMessageListener listener)
 
void addConversationListener (EMConversationListener listener)
 
void removeConversationListener (EMConversationListener listener)
 
void setMessageListened (EMMessage message)
 

Protected Member Functions

 EMChatManager (EMClient client, EMAChatManager manager)
 

Detailed Description

send a message
EMMessage msg = EMMessage;
EMClient.getInstance().chatManager().sendMessage(msg);

Member Function Documentation

void com.hyphenate.chat.EMChatManager.ackMessageRead ( String  to,
String  messageId 
) throws HyphenateException

send read ack to server

Parameters
tothe recipient id
messageIdmessage id
Exceptions
HyphenateException
void com.hyphenate.chat.EMChatManager.addConversationListener ( EMConversationListener  listener)

add conversation listener

See also
EMConversationListener

refresh the conversation list when receiving the conversation refresh event

Parameters
listenerthe conversation listener
void com.hyphenate.chat.EMChatManager.addMessageListener ( EMMessageListener  listener)

add message listener

See also
EMMessageListener
Parameters
listenerthe message listener which is used to monitor the incoming messages
boolean com.hyphenate.chat.EMChatManager.deleteConversation ( String  username,
boolean  deleteMessages 
)

delete conversation and all history messages

Parameters
usernameuser id or group id
deleteMessageswhether delete messages
Returns
return true if delete successfully
void com.hyphenate.chat.EMChatManager.downloadAttachment ( final EMMessage  msg)

download the attachement again if not downloaded before

Parameters
msgmsg the msg to be downloaded
void com.hyphenate.chat.EMChatManager.downloadFile ( final String  remoteUrl,
final String  localFilePath,
final Map< String, String >  headers,
final EMCallBack  callback 
)

download the file from server

Parameters
remoteUrlthe remote file url
localFilePaththe local file path
headersHttp Request Headers
callbackEMCallBack
void com.hyphenate.chat.EMChatManager.downloadThumbnail ( final EMMessage  msg)

download the thumbnail if not downloaded before

Parameters
msgthe msg to be downloaded
Map<String, EMConversation> com.hyphenate.chat.EMChatManager.getAllConversations ( )

get all conversations in the cache

Returns
conversations which is a map with key->conversation id : value->EMConversation
EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String  id)

get conversation by id

Parameters
iduser id, group id or chatroom id EMConversation the existing conversation found by conversation, null if not found
EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String  id,
EMConversationType  type 
)

get conversation by conversation id and conversation type, create a empty conversation if not found

Parameters
iduser id, group id or chatroom id
type
See also
EMConversationType the conversation type EMConversation the conversation found according to the id and type, create a empty conversation if not found
EMConversation com.hyphenate.chat.EMChatManager.getConversation ( String  username,
EMConversationType  type,
boolean  createIfNotExists 
)

get conversation by conversation id and conversation type

Parameters
usernameuser id, group id or chatroom id
type
See also
EMConversationType the conversation type
Parameters
createIfNotExistscreate conversation if not exists
List<EMConversation> com.hyphenate.chat.EMChatManager.getConversationsByType ( EMConversation.EMConversationType  type)

get list of conversations by conversation type

Returns
the conversation list of this type
EMMessage com.hyphenate.chat.EMChatManager.getMessage ( String  messageId)

get message through message id

Parameters
messageIdmessage id
Returns
int com.hyphenate.chat.EMChatManager.getUnreadMsgsCount ( )

get unread message count

Returns
synchronized void com.hyphenate.chat.EMChatManager.importMessages ( List< EMMessage msgs)

import messages to db,ensure the meessage's sender or receiver is current user

Parameters
msgsthe message list of be imported
boolean com.hyphenate.chat.EMChatManager.isSlientMessage ( EMMessage  message)

check if the message is kind of slient message, if that's it, app should not play tone or vibrate

Parameters
message
Returns
void com.hyphenate.chat.EMChatManager.loadAllConversations ( )

load all conversatons from db

void com.hyphenate.chat.EMChatManager.markAllConversationsAsRead ( )

mark all messages as read

void com.hyphenate.chat.EMChatManager.removeConversationListener ( EMConversationListener  listener)

remove the conversation listener

Parameters
listenerthe conversation listener set before
void com.hyphenate.chat.EMChatManager.removeMessageListener ( EMMessageListener  listener)

remove the message listener

Parameters
listenerthe message listener set before
void com.hyphenate.chat.EMChatManager.saveMessage ( EMMessage  message)

save the message to memory and db

Parameters
message
void com.hyphenate.chat.EMChatManager.sendMessage ( final EMMessage  msg)

send message asynchronously and you can set this message status callback through EMMessage.setMessageStatusCallback

Parameters
msg
Exceptions
HyphenateException
void com.hyphenate.chat.EMChatManager.setMessageListened ( EMMessage  message)

set message to listened, usually use for voice message

boolean com.hyphenate.chat.EMChatManager.updateMessage ( EMMessage  message)

update the message

Parameters
message

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