agora_chat_SDK 1.0.6
agora java chat SDK
Public Member Functions | Protected Member Functions | List of all members
io.agora.chat.ChatManager Class Reference

Public Member Functions

void sendMessage (final ChatMessage msg)
 
void ackConversationRead (String conversationId) throws ChatException
 
void ackMessageRead (String to, String messageId) throws ChatException
 
void ackGroupMessageRead (String to, String messageId, String ext) throws ChatException
 
void recallMessage (ChatMessage message) throws ChatException
 
void aysncRecallMessage (final ChatMessage message, final CallBack callback)
 
ChatMessage getMessage (String messageId)
 
Conversation getConversation (String id)
 
Conversation getConversation (String id, ConversationType type)
 
Conversation getConversation (String username, ConversationType type, boolean createIfNotExists)
 
Conversation getConversation (String username, ConversationType type, boolean createIfNotExists, boolean isChatThread)
 
void markAllConversationsAsRead ()
 
int getUnreadMsgsCount ()
 
int getUnreadMessageCount ()
 
void saveMessage (ChatMessage message)
 
boolean updateMessage (ChatMessage message)
 
void downloadAttachment (final ChatMessage msg)
 
void downloadThumbnail (final ChatMessage msg)
 
synchronized void importMessages (List< ChatMessage > msgs)
 
List< ConversationgetConversationsByType (ConversationType type)
 
void downloadFile (final String remoteUrl, final String localFilePath, final Map< String, String > headers, final CallBack callback)
 
Map< String, ConversationgetAllConversations ()
 
Map< String, ConversationfetchConversationsFromServer () throws ChatException
 
void asyncFetchConversationsFromServer (final ValueCallBack< Map< String, Conversation > > callBack)
 
void loadAllConversations ()
 
boolean deleteConversation (String username, boolean deleteMessages)
 
void deleteConversationFromServer (String username, ConversationType type, boolean isDeleteServerMessages, CallBack deleteCallBack)
 
void addMessageListener (MessageListener listener)
 
void removeMessageListener (MessageListener listener)
 
void addConversationListener (ConversationListener listener)
 
void removeConversationListener (ConversationListener listener)
 
void setMessageListened (ChatMessage message)
 
void setVoiceMessageListened (ChatMessage message)
 
boolean updateParticipant (String from, String changeTo)
 
CursorResult< GroupReadAckfetchGroupReadAcks (String msgId, int pageSize, String startAckId) throws ChatException
 
void asyncFetchGroupReadAcks (final String msgId, final int pageSize, final String startAckId, final ValueCallBack< CursorResult< GroupReadAck > > callBack)
 
CursorResult< ChatMessagefetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String startMsgId) throws ChatException
 
CursorResult< ChatMessagefetchHistoryMessages (String conversationId, ConversationType type, int pageSize, String startMsgId, Conversation.SearchDirection direction) throws ChatException
 
void asyncFetchHistoryMessage (final String conversationId, final ConversationType type, final int pageSize, final String startMsgId, final ValueCallBack< CursorResult< ChatMessage > > callBack)
 
void asyncFetchHistoryMessage (final String conversationId, final ConversationType type, final int pageSize, final String startMsgId, final Conversation.SearchDirection direction, final ValueCallBack< CursorResult< ChatMessage > > callBack)
 
List< ChatMessagesearchMsgFromDB (ChatMessage.Type type, long timeStamp, int maxCount, String from, Conversation.SearchDirection direction)
 
List< ChatMessagesearchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, Conversation.SearchDirection direction)
 
void deleteMessagesBeforeTimestamp (long timeStamp, CallBack callback)
 
void asyncReportMessage (String msgId, String reportTarget, String reportReason, CallBack callBack)
 
void reportMessage (String msgId, String reportTarget, String reportReason) throws ChatException
 
void fetchSupportLanguages (ValueCallBack< List< Language > > callBack)
 
void translateMessage (ChatMessage message, List< String > languages, ValueCallBack< ChatMessage > callBack)
 
void addReaction (final String messageId, final String reaction) throws ChatException
 
void asyncAddReaction (final String messageId, final String reaction, final CallBack callback)
 
void removeReaction (final String messageId, final String reaction) throws ChatException
 
void asyncRemoveReaction (final String messageId, final String reaction, final CallBack callback)
 
Map< String, List< MessageReaction > > getReactionList (final List< String > messageIdList, final ChatMessage.ChatType chatType, final String groupId) throws ChatException
 
void asyncGetReactionList (final List< String > messageIdList, final ChatMessage.ChatType chatType, final String groupId, final ValueCallBack< Map< String, List< MessageReaction > > > callback)
 
CursorResult< MessageReactiongetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize) throws ChatException
 
void asyncGetReactionDetail (final String messageId, final String reaction, final String cursor, final int pageSize, final ValueCallBack< CursorResult< MessageReaction > > callback)
 

Protected Member Functions

 ChatManager (ChatClient client, EMAChatManager manager, EMAReactionManager reactionManager)
 

Detailed Description

The chat manager. This class is responsible for managing conversations. (such as: load, delete), sending messages, downloading attachments and so on.

Such as, send a text message:

ChatMessage message = ChatMessage.createTxtSendMessage(content, toChatUsername);
ChatClient.getInstance().chatManager().sendMessage(message);

Member Function Documentation

◆ ackConversationRead()

void io.agora.chat.ChatManager.ackConversationRead ( String  conversationId) throws ChatException

Sends the conversation read receipt to the server. This method is only for one-to-one chat conversation.

This method will inform the sever to set the unread message count of the conversation to 0, and conversationist (with multiple devices) will receive a callback method from ConversationListener#onConversationRead(String, String).

Reference: If you want to send group message read receipt to the sever, see ackGroupMessageRead(String, String, String).

Parameters
conversationIdThe conversation ID.
Exceptions
ChatExceptionThe possible exceptions are as follows: Error#USER_NOT_LOGIN, Error#SERVER_NOT_REACHABLE, Error#MESSAGE_INVALID and so on, see Error.

◆ ackGroupMessageRead()

void io.agora.chat.ChatManager.ackGroupMessageRead ( String  to,
String  messageId,
String  ext 
) throws ChatException

Sends the group message receipt to the server.

You can only call the method after setting the following method: ChatOptions#setRequireAck(boolean) and ChatMessage#setIsNeedGroupAck(boolean).

Reference: To send the one-to-one chat message receipt to server, call ackMessageRead(String, String); To send the conversation receipt to the server, call ackConversationRead(String).

Parameters
toThe conversation ID.
messageIdThe message ID.
extThe extension information. Developer self-defined command string that can be used for specifying custom action/command.
Exceptions
ChatExceptionA description of the exception, see Error.

◆ ackMessageRead()

void io.agora.chat.ChatManager.ackMessageRead ( String  to,
String  messageId 
) throws ChatException

Sends the read receipt to the server.

This method applies to one-to-one chats only.

Warning This method only takes effect if you set ChatOptions#setRequireAck(boolean) as true.

Reference: To send the group message read receipt, call ackGroupMessageRead(String, String, String).

We recommend that you call ackConversationRead(String) when entering a chat page, and call this method in other cases to reduce the number of method calls.

Parameters
toThe receiver of the read receipt.
messageIdThe message ID.
Exceptions
ChatExceptionA description of the exception, see Error.

◆ addConversationListener()

void io.agora.chat.ChatManager.addConversationListener ( ConversationListener  listener)

Adds the conversation listener.

The method is used to listen the change of conversation and listen the receipt of the conversation message, see ConversationListener.

After set this method, if you want to remove the conversation listener, you can call the method of removeConversationListener(ConversationListener) to remove it.

Parameters
listenerThe conversation listener to be set, see ConversationListener.

◆ addMessageListener()

void io.agora.chat.ChatManager.addMessageListener ( MessageListener  listener)

Adds the message listener.

Receives new messages and so on can set the method to listen, see MessageListener.

Parameters
listenerThe message listener which is used to listen the incoming messages, see MessageListener

◆ addReaction()

void io.agora.chat.ChatManager.addReaction ( final String  messageId,
final String  reaction 
) throws ChatException

Adds a reaction.

This is a synchronous method and blocks the current thread.

Parameters
messageIdThe message ID.
reactionThe reaction content.
Exceptions
ChatExceptionA description of the exception. See Error.

◆ asyncAddReaction()

void io.agora.chat.ChatManager.asyncAddReaction ( final String  messageId,
final String  reaction,
final CallBack  callback 
)

Adds a reaction.

This is an asynchronous method.

Parameters
messageIdThe message ID.
reactionThe message reaction.
callbackThe result callback which contains the error information if the method fails.

◆ asyncFetchConversationsFromServer()

void io.agora.chat.ChatManager.asyncFetchConversationsFromServer ( final ValueCallBack< Map< String, Conversation > >  callBack)

Fetches conversations from the server. The default maximum return is 100.

This is an asynchronous method.

Returns
Returns the conversation list of the current log-in user.

◆ asyncFetchGroupReadAcks()

void io.agora.chat.ChatManager.asyncFetchGroupReadAcks ( final String  msgId,
final int  pageSize,
final String  startAckId,
final ValueCallBack< CursorResult< GroupReadAck > >  callBack 
)

Fetches the ack details for group messages from server.

Fetches by page.

Reference: If you want to send group message receipt, see ackConversationRead(String).

This is an asynchronous method.

Parameters
msgIdThe message ID.
pageSizeThe number of records per page.
startAckIdThe start ID for fetch receipts, can be null. If you set it as null, the SDK will start from the server's latest receipt.
callBackThe result callback, if successful, the SDK will execute the method ValueCallBack#onSuccess(Object), if the call failed, the SDK will execute the method ValueCallBack#onError(int, String).

◆ asyncFetchHistoryMessage() [1/2]

void io.agora.chat.ChatManager.asyncFetchHistoryMessage ( final String  conversationId,
final ConversationType  type,
final int  pageSize,
final String  startMsgId,
final Conversation.SearchDirection  direction,
final ValueCallBack< CursorResult< ChatMessage > >  callBack 
)

Fetches the message history of the conversation from the server.

Fetches by page.

This is an asynchronous method.

Parameters
conversationIdThe conversation id which select to fetch roam message.
typeThe conversation type which select to fetch roam message.
pageSizeThe number of records per page.
startMsgIdThe start search roam message, if the param is empty, direction is io.agora.chat.Conversation.SearchDirection#UP , fetches from the server latest message, direction is io.agora.chat.Conversation.SearchDirection#DOWN , fetches from the server oldest message.
directionRoaming message retrieval direction, io.agora.chat.Conversation.SearchDirection#UP is the retrieval time stamp message less than the start message time stamp, io.agora.chat.Conversation.SearchDirection#DOWN is a message whose retrieval timestamp is greater than the timestamp of the start message.
callBackThe result callback, if successful, the SDK will execute the method ValueCallBack#onSuccess(Object), which returns messages from server and cursor for next fetch action; if the call failed, the SDK will execute the method ValueCallBack#onError(int, String).

◆ asyncFetchHistoryMessage() [2/2]

void io.agora.chat.ChatManager.asyncFetchHistoryMessage ( final String  conversationId,
final ConversationType  type,
final int  pageSize,
final String  startMsgId,
final ValueCallBack< CursorResult< ChatMessage > >  callBack 
)

Fetches the message history of the conversation from the server.

Fetches by page.

This is an asynchronous method.

Parameters
conversationIdThe conversation id which select to fetch roam message.
typeThe conversation type which select to fetch roam message.
pageSizeThe number of records per page.
startMsgIdThe start search roam message, if empty start from the server latest message.
callBackThe result callback, if successful, the SDK will execute the method ValueCallBack#onSuccess(Object), which returns messages from server and cursor for next fetch action; if the call failed, the SDK will execute the method ValueCallBack#onError(int, String).

◆ asyncGetReactionDetail()

void io.agora.chat.ChatManager.asyncGetReactionDetail ( final String  messageId,
final String  reaction,
final String  cursor,
final int  pageSize,
final ValueCallBack< CursorResult< MessageReaction > >  callback 
)

Gets the reaction details.

This is an asynchronous method.

Parameters
messageIdThe message ID.
reactionThe reaction content.
cursorThe query cursor.
pageSizeThe number of Reactions you expect to get on each page.
callbackThe result callback, which contains the reaction list obtained from the server and the cursor for the next query. Returns null if all the data is fetched.

◆ asyncGetReactionList()

void io.agora.chat.ChatManager.asyncGetReactionList ( final List< String >  messageIdList,
final ChatMessage.ChatType  chatType,
final String  groupId,
final ValueCallBack< Map< String, List< MessageReaction > > >  callback 
)

Gets the list of Reactions.

This is an asynchronous method.

Parameters
messageIdListThe message ID.
chatTypeThe chat type. Only one-to-one chat (ChatMessage.ChatType#Chat and group chat (ChatMessage.ChatType#GroupChat) are allowed.
groupIdThe group ID, which is invalid only when the chat type is group chat.
callbackThe result callback, which contains the Reaction list under the specified message ID(The user list of MessageReaction is the summary data, which only contains the information of the first three users).

◆ asyncRemoveReaction()

void io.agora.chat.ChatManager.asyncRemoveReaction ( final String  messageId,
final String  reaction,
final CallBack  callback 
)

Deletes a reaction.

This is an asynchronous method.

Parameters
messageIdThe message ID.
reactionThe reaction content.
callbackThe result callback which contains the error information if the method fails.

◆ asyncReportMessage()

void io.agora.chat.ChatManager.asyncReportMessage ( String  msgId,
String  reportTarget,
String  reportReason,
CallBack  callBack 
)

Report violation message

Parameters
msgIdViolation Message ID
reportTargetReport type (For example: involving pornography and terrorism)
reportReasonReport Reason
callBackThe result callback,see CallBack.

◆ aysncRecallMessage()

void io.agora.chat.ChatManager.aysncRecallMessage ( final ChatMessage  message,
final CallBack  callback 
)

Recalls the sent message.

This is an asynchronous method.

Parameters
messageThe message object.
callbackAn instance of the CallBack class, see CallBack.

◆ deleteConversation()

boolean io.agora.chat.ChatManager.deleteConversation ( String  username,
boolean  deleteMessages 
)

Deletes conversation and messages from the local database.

If you set deleteMessages to true, delete the local chat history when delete the conversation.

Parameters
usernameThe conversation ID.
deleteMessagesWhether to delete the chat history when delete the conversation.
  • True means to delete the chat history when delete the conversation;
  • false means not.
Returns
The result of deleting.
  • True means success;
  • false means failure.

◆ deleteConversationFromServer()

void io.agora.chat.ChatManager.deleteConversationFromServer ( String  username,
ConversationType  type,
boolean  isDeleteServerMessages,
CallBack  deleteCallBack 
)

Deletes the conversation of a specified ID and it's chat records on the server. This operation is performed asynchronously.

Parameters
usernameConversation ID.
typeconversation type ConversationType
isDeleteServerMessagesWhether to delete the server chat records when delete conversation.
  • True means to delete the chat history when delete the conversation;
  • false means not.
deleteCallBackThe callback to delete the server session and record successfully.
  • True means success;
  • false means failure.

◆ deleteMessagesBeforeTimestamp()

void io.agora.chat.ChatManager.deleteMessagesBeforeTimestamp ( long  timeStamp,
CallBack  callback 
)

Deletes the local message record before the timestamp.

Parameters
timeStampThe Unix timestamp, in milliseconds.
callbackThe result callback,see CallBack.

◆ downloadAttachment()

void io.agora.chat.ChatManager.downloadAttachment ( final ChatMessage  msg)

Downloads the message attachment.

You can call the method again if the attachment download fails.

Parameters
msgThe message to be download the attachment.

◆ downloadFile()

void io.agora.chat.ChatManager.downloadFile ( final String  remoteUrl,
final String  localFilePath,
final Map< String, String >  headers,
final CallBack  callback 
)

Downloads the attachment files from the server.

Parameters
remoteUrlThe remote file url.
localFilePathThe local file path.
headersThe Http Request Headers.
callbackThe download status callback, see CallBack.
Deprecated:
Use downloadAttachment(ChatMessage) instead.

◆ downloadThumbnail()

void io.agora.chat.ChatManager.downloadThumbnail ( final ChatMessage  msg)

Downloads the thumbnail if the msg is not downloaded before or the download failed.

Parameters
msgThe message object.

◆ fetchConversationsFromServer()

Map< String, Conversation > io.agora.chat.ChatManager.fetchConversationsFromServer ( ) throws ChatException

Fetches the conversation list from the server. The default maximum return is 100.

This is a synchronous method and blocks the current thread.

Returns
Returns the conversation list of the current user.

◆ fetchGroupReadAcks()

CursorResult< GroupReadAck > io.agora.chat.ChatManager.fetchGroupReadAcks ( String  msgId,
int  pageSize,
String  startAckId 
) throws ChatException

Fetches the receipt details for group messages from the server.

Fetches by page.

Reference: If you want to send group message read receipt, see ackConversationRead(String)

This is a synchronous method and blocks the current thread.

Parameters
msgIdThe message ID which needs to fetch receipt.
pageSizeThe number of records per page.
startAckIdThe start ID for fetching receipts, can be null. If you set it as null, the fetching will start from the server‘s latest receipt.
Returns
The list of returned ack from the server and the cursor for next fetch action.
Exceptions
ChatExceptionA description of the exception, see Error.

◆ fetchHistoryMessages() [1/2]

CursorResult< ChatMessage > io.agora.chat.ChatManager.fetchHistoryMessages ( String  conversationId,
ConversationType  type,
int  pageSize,
String  startMsgId 
) throws ChatException

Fetches history messages of the conversation from the server.

Fetches by page.

This is a synchronous method and blocks the current thread.

Parameters
conversationIdThe conversation ID.
typeThe conversation type which select to fetch roam message, see ConversationType
pageSizeThe number of records per page.
startMsgIdThe start search roam message, if the param is empty, fetches from the server latest message.
Returns
Returns the messages and the cursor for next fetch action.
Exceptions
ChatExceptionA description of the exception, see Error.

◆ fetchHistoryMessages() [2/2]

CursorResult< ChatMessage > io.agora.chat.ChatManager.fetchHistoryMessages ( String  conversationId,
ConversationType  type,
int  pageSize,
String  startMsgId,
Conversation.SearchDirection  direction 
) throws ChatException

Fetches history messages of the conversation from the server.

Fetches by page.

This is a synchronous method and blocks the current thread.

Parameters
conversationIdThe conversation ID.
typeThe conversation type which select to fetch roam message, see ConversationType
pageSizeThe number of records per page.
startMsgIdThe start search roam message, if the param is empty, direction is io.agora.chat.Conversation.SearchDirection#UP , fetches from the server latest message, direction is io.agora.chat.Conversation.SearchDirection#DOWN , fetches from the server oldest message.
directionRoaming message retrieval direction, io.agora.chat.Conversation.SearchDirection#UP is the retrieval time stamp message less than the start message time stamp, io.agora.chat.Conversation.SearchDirection#DOWN is a message whose retrieval timestamp is greater than the timestamp of the start message.
Returns
Returns the messages and the cursor for next fetch action.
Exceptions
ChatExceptionA description of the exception, see Error.

◆ fetchSupportLanguages()

void io.agora.chat.ChatManager.fetchSupportLanguages ( ValueCallBack< List< Language > >  callBack)

获取翻译服务支持的语言

Parameters
callBack完成回调

Fetch all languages what the translate service support

Parameters
callBackComplete the callback

◆ getAllConversations()

Map< String, Conversation > io.agora.chat.ChatManager.getAllConversations ( )

Gets all conversations from the local database.

Conversations will be loaded from memory first, if no conversation is found then the SDk loads from the local database.

Returns
Returns all the conversations from the memory or local database.

◆ getConversation() [1/4]

Conversation io.agora.chat.ChatManager.getConversation ( String  id)

Gets the conversation object by the specified ID.

The SDK wil return null if the conversation is not found.

Parameters
idThe conversation ID.
Returns
The existing conversation found by conversation ID. Returns null if the conversation is not found.

◆ getConversation() [2/4]

Conversation io.agora.chat.ChatManager.getConversation ( String  id,
ConversationType  type 
)

Gets the conversation by conversation ID and conversation type.

The SDK wil return null if the conversation is not found.

Parameters
idThe conversation ID.
typeThe conversation type, see ConversationType
Returns
The conversation object found according to the id and type. Returns null if the conversation is not found.

◆ getConversation() [3/4]

Conversation io.agora.chat.ChatManager.getConversation ( String  username,
ConversationType  type,
boolean  createIfNotExists 
)

Get the conversation object by conversation ID and conversation type.

If the conversation is not found, you can create a new object based on the value of CreateIFNotExists or an empty object.

Parameters
usernameThe conversation ID.
typeThe conversation type, see ConversationType.
createIfNotExistsWhether to create a conversation if not find the specified conversation.
  • true means create one;
  • false means not.
Returns
The conversation object found according to the ID and type. Returns null if the conversation is not found.

◆ getConversation() [4/4]

Conversation io.agora.chat.ChatManager.getConversation ( String  username,
ConversationType  type,
boolean  createIfNotExists,
boolean  isChatThread 
)

Get conversation object by conversation id and conversation type.

If the conversation is not found, you can create a new object based on the value of CreateIFNotExists or an empty object.

Parameters
usernameThe conversation ID.
typeThe conversation type, see ConversationType.
createIfNotExistsWhether to create a conversation if not find the specified conversation.
  • true means create one;
  • false means not.
isChatThreadWhether to search chat thread conversation.
  • true means search chat thread conversation;
    • false means not.
Returns
The conversation object found according to the ID and type. Returns null if the conversation is not found.

◆ getConversationsByType()

List< Conversation > io.agora.chat.ChatManager.getConversationsByType ( ConversationType  type)

Gets the list of conversations by conversation type.

Parameters
typeThe conversation type, see ConversationType.
Returns
The list of conversation in specified type.

◆ getMessage()

ChatMessage io.agora.chat.ChatManager.getMessage ( String  messageId)

Fetches messages by message ID.

Parameters
messageIdThe message ID.
Returns
The message object obtained by the specified ID. Returns null if the message doesn't exist.

◆ getReactionDetail()

CursorResult< MessageReaction > io.agora.chat.ChatManager.getReactionDetail ( final String  messageId,
final String  reaction,
final String  cursor,
final int  pageSize 
) throws ChatException

Gets the reaction details.

This is a synchronous method and blocks the current thread.

Parameters
messageIdThe message ID.
reactionThe reaction content.
cursorThe cursor position from which to get Reactions.
pageSizeThe number of Reactions you expect to get on each page.
Returns
CursorResult The result callback, which contains the reaction list obtained from the server and the cursor for the next query. Returns null if all the data is fetched.
Exceptions
ChatExceptionA description of the exception, see Error.

◆ getReactionList()

Map< String, List< MessageReaction > > io.agora.chat.ChatManager.getReactionList ( final List< String >  messageIdList,
final ChatMessage.ChatType  chatType,
final String  groupId 
) throws ChatException

Gets the list of Reactions.

This is a synchronous method and blocks the current thread.

Parameters
messageIdListThe message ID.
chatTypeThe chat type. Only one-to-one chat (ChatMessage.ChatType#Chat and group chat (ChatMessage.ChatType#GroupChat) are allowed.
groupIdThe group ID, which is invalid only when the chat type is group chat.
Returns
map The Reaction list under the specified message ID(The UserList of MessageReaction is the summary data, which only contains the information of the first three users).
Exceptions
ChatExceptionA description of the exception. See Error.

◆ getUnreadMessageCount()

int io.agora.chat.ChatManager.getUnreadMessageCount ( )

Gets the unread message count.

Returns
The count of unread messages.

◆ getUnreadMsgsCount()

int io.agora.chat.ChatManager.getUnreadMsgsCount ( )

Gets the unread message count.

Returns
The count of unread messages.
Deprecated:
Use ChatManager#getUnreadMessageCount() instead.

◆ importMessages()

synchronized void io.agora.chat.ChatManager.importMessages ( List< ChatMessage msgs)

Imports messages to the local database.

Make sure the message sender or receiver is the current user before option.

Recommends import less than 1,000 messages per operation.

Parameters
msgsThe message list.

◆ loadAllConversations()

void io.agora.chat.ChatManager.loadAllConversations ( )

Loads all conversations from the local database into memory. Generally used after a successful login to speed up the loading of the conversation list.

◆ markAllConversationsAsRead()

void io.agora.chat.ChatManager.markAllConversationsAsRead ( )

Marks all messages as read.

This method is for the local conversations only.

◆ recallMessage()

void io.agora.chat.ChatManager.recallMessage ( ChatMessage  message) throws ChatException

Recalls the sent message.

This is a synchronous method and blocks the current thread.

Parameters
messageThe message instance.
Exceptions
ChatExceptionA description of the exception. See Error.

◆ removeConversationListener()

void io.agora.chat.ChatManager.removeConversationListener ( ConversationListener  listener)

Removes the conversation listener.

Make sure to use the addConversationListener(ConversationListener) method first if you want to delete the conversation listener.

Parameters
listenerThe conversation listener to be removed.

◆ removeMessageListener()

void io.agora.chat.ChatManager.removeMessageListener ( MessageListener  listener)

Removes the message listener.

You should call this method after set addMessageListener(MessageListener) .

Parameters
listenerThe message listener to be removed.

◆ removeReaction()

void io.agora.chat.ChatManager.removeReaction ( final String  messageId,
final String  reaction 
) throws ChatException

Deletes a reaction.

This is a synchronous method and blocks the current thread.

Parameters
messageIdThe message ID.
reactionThe message reaction.
Exceptions
ChatExceptionA description of the exception. See Error.

◆ reportMessage()

void io.agora.chat.ChatManager.reportMessage ( String  msgId,
String  reportTarget,
String  reportReason 
) throws ChatException

Report violation message

Parameters
msgIdViolation Message ID
reportTargetReport type (For example: involving pornography and terrorism)
reportReasonReport Reason
Exceptions
ChatExceptionA description of the exception. See Error.

◆ saveMessage()

void io.agora.chat.ChatManager.saveMessage ( ChatMessage  message)

Saves the message to the memory and local database.

Notes: The CMD message will not be stored in the database.

Parameters
messageThe message to store.

◆ searchMsgFromDB() [1/2]

List< ChatMessage > io.agora.chat.ChatManager.searchMsgFromDB ( ChatMessage.Type  type,
long  timeStamp,
int  maxCount,
String  from,
Conversation.SearchDirection  direction 
)

Searches messages from the local database according the parameters.

Note: Be cautious about the memory usage when the maxCount is large, currently the limited number is 400 entries at a time.

Parameters
typeThe message type, TXT、VOICE、IMAGE、VIDEO and so on, see ChatMessage.Type.
timeStampThe Unix timestamp when searching, in milliseconds.
maxCountThe max number of message to search.
fromA user ID or a group ID searches for messages, usually refers to the conversation ID.
Returns
The list of messages.

◆ searchMsgFromDB() [2/2]

List< ChatMessage > io.agora.chat.ChatManager.searchMsgFromDB ( String  keywords,
long  timeStamp,
int  maxCount,
String  from,
Conversation.SearchDirection  direction 
)

Searches messages from the database according to the parameters.

Note: Cautious about the memory usage when the maxCount is large, currently the limited number is 400 entries at a time.

Parameters
keywordsThe keywords in message.
timeStampThe timestamp for search, Unix timestamp, in milliseconds.
maxCountThe max number of message to search at a time.
fromA user ID or a group ID searches for messages, usually refers to the conversation ID.
Returns
The list of messages.

◆ sendMessage()

void io.agora.chat.ChatManager.sendMessage ( final ChatMessage  msg)

Sends a message。

Reference: If the message is voice, picture and other message with attachment, the SDK will automatically upload the attachment. You can set whether to upload the attachment to the chat sever by ChatOptions#setAutoTransferMessageAttachments(boolean).

To listen for the status of sending messages, call ChatMessage#setMessageStatusCallback(CallBack).

Parameters
msgThe message object to be sent. Make sure to set the param.

◆ setMessageListened()

void io.agora.chat.ChatManager.setMessageListened ( ChatMessage  message)

Sets the message status as listened. Usually used for voice messages.

Parameters
messageThe message object.
Deprecated:
Use ChatManager#setVoiceMessageListened(ChatMessage) instead.

◆ setVoiceMessageListened()

void io.agora.chat.ChatManager.setVoiceMessageListened ( ChatMessage  message)

Sets the message status as listened. Usually used for voice messages.

Parameters
messageThe message object.

◆ translateMessage()

void io.agora.chat.ChatManager.translateMessage ( ChatMessage  message,
List< String >  languages,
ValueCallBack< ChatMessage callBack 
)

translate a message

Parameters
messageThe message object
languagesList of target language codes to translate
callBackComplete the callback

◆ updateMessage()

boolean io.agora.chat.ChatManager.updateMessage ( ChatMessage  message)

Updates the local message.

Will update the memory and the local database at the same time.

Parameters
messageThe message objects to update.

◆ updateParticipant()

boolean io.agora.chat.ChatManager.updateParticipant ( String  from,
String  changeTo 
)

Updates the database records, changes username from 'from' to 'changeTo'. The method will effect on other counts, such as the message table, the conversation table, contacts, the blocklist table.

Note: this operation does not update the data stored in memory cache.

Parameters
fromThe user ID before replace.
changeToThe user ID after replace.
Returns
The operation result. If any update operations on those tables failed, the SDK will return false.

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