|
Set< EMMarkType > | marks () |
|
String | conversationId () |
|
ConversationType | getType () |
|
int | getUnreadMsgCount () |
|
void | markAllMessagesAsRead () |
|
int | getAllMsgCount () |
|
int | getAllMsgCount (long startTimestamp, long endTimestamp) |
|
boolean | isChatThread () |
|
List< ChatMessage > | loadMoreMsgFromDB (String startMsgId, int pageSize) |
|
List< ChatMessage > | loadMoreMsgFromDB (String startMsgId, int pageSize, SearchDirection direction) |
|
List< ChatMessage > | searchMsgFromDB (long timeStamp, int maxCount, SearchDirection direction) |
|
List< ChatMessage > | searchMsgFromDB (Type type, long timeStamp, int maxCount, String from, SearchDirection direction) |
|
List< ChatMessage > | searchMsgFromDB (Set< Type > types, long timeStamp, int maxCount, String from, SearchDirection direction) |
|
List< ChatMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, SearchDirection direction) |
|
List< ChatMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, SearchDirection direction, ChatMessageSearchScope searchScope) |
|
List< ChatMessage > | searchMsgFromDB (long startTimeStamp, long endTimeStamp, int maxCount) |
|
List< ChatMessage > | searchCustomMsgFromDB (String keywords, long timeStamp, int maxCount, String from, SearchDirection direction) |
|
ChatMessage | getMessage (String messageId, boolean markAsRead) |
|
void | markMessageAsRead (String messageId) |
|
List< ChatMessage > | getAllMessages () |
|
void | removeMessage (String messageId) |
|
ChatMessage | getLastMessage () |
|
ChatMessage | getLatestMessageFromOthers () |
|
void | clear () |
|
void | clearAllMessages () |
|
void | setExtField (String ext) |
|
String | getExtField () |
|
boolean | isPinned () |
|
long | getPinnedTime () |
|
boolean | isGroup () |
|
boolean | insertMessage (ChatMessage msg) |
|
boolean | appendMessage (ChatMessage msg) |
|
boolean | updateMessage (ChatMessage msg) |
|
String | getMessageAttachmentPath () |
|
void | removeMessagesFromServer (List< String > msgIdList, CallBack callBack) |
|
void | removeMessagesFromServer (long beforeTimeStamp, CallBack callBack) |
|
boolean | removeMessages (long startTime, long endTime) |
|
List< ChatMessage > | pinnedMessages () |
|
PushManager.PushRemindType | pushRemindType () |
|
The conversation class, which defines one-to-one conversations, group conversations, and chat room conversations.
Each type of conversation involves messages that are sent and received.
The following code shows how to get the number of the unread messages from the conversation.
Definition ChatClient.java:88
Conversation getConversation(String id)
Definition ChatManager.java:961
int getUnreadMsgCount()
Definition Conversation.java:204
String conversationId()
Definition Conversation.java:174
◆ appendMessage()
boolean io.agora.chat.Conversation.appendMessage |
( |
ChatMessage | msg | ) |
|
Inserts a message to the end of the conversation in the local database.
To insert the message correctly, ensure that the conversation ID of the message is the same as that of the conversation.
After a message is inserted, the SDK will automatically update attributes of the conversation, including latestMessage
.
- Parameters
-
◆ clear()
void io.agora.chat.Conversation.clear |
( |
| ) |
|
Deletes all the messages in the conversation.
This method only deletes all the messages in a conversation in the memory, but not the messages in the local database.
When exiting a conversation, you need to clear the memory to reduce the memory consumption.
◆ clearAllMessages()
void io.agora.chat.Conversation.clearAllMessages |
( |
| ) |
|
Deletes all the messages in the conversation from the memory and local database.
◆ conversationId()
String io.agora.chat.Conversation.conversationId |
( |
| ) |
|
The conversation ID, which depends on the conversation type.
- One-to-one chat/help desk: The conversation ID is the user ID of the peer user.
- Group chat: The conversation ID is the group ID.
- Chat room: The conversation ID is the chat room ID.
- Returns
- The conversation ID.
◆ getAllMessages()
List< ChatMessage > io.agora.chat.Conversation.getAllMessages |
( |
| ) |
|
Gets all messages of the conversation in the local memory.
If no message is found in the memory, the SDK will load the latest message from the local database.
- Returns
- The message list.
◆ getAllMsgCount() [1/2]
int io.agora.chat.Conversation.getAllMsgCount |
( |
| ) |
|
Gets the number of all messages in the conversation in the local database.
- Returns
- The number of all messages in the conversation.
◆ getAllMsgCount() [2/2]
int io.agora.chat.Conversation.getAllMsgCount |
( |
long | startTimestamp, |
|
|
long | endTimestamp ) |
Gets the number of all messages in the conversation in the local database within a specific time period.
- Parameters
-
startTimestamp | The start timestamp (inclusive) in milliseconds. |
endTimestamp | The end timestamp (inclusive) in milliseconds. |
- Returns
- The number of all messages in the conversation within a specific time period.
◆ getExtField()
String io.agora.chat.Conversation.getExtField |
( |
| ) |
|
Gets the extension field of the conversation.
The extension field is only stored in the local database, but not synchronized to the server.
The extension field of a chat thread conversation is not saved in the local database.
- Returns
- The extension content.
◆ getLastMessage()
ChatMessage io.agora.chat.Conversation.getLastMessage |
( |
| ) |
|
Gets the latest message in the conversation.
A call to this method has no impact on the number of unread messages.
The SDK first retrieves the message from the memory. If no message is found, the SDK will retrieve it from the local database and load it.
- Returns
- The message instance.
◆ getLatestMessageFromOthers()
ChatMessage io.agora.chat.Conversation.getLatestMessageFromOthers |
( |
| ) |
|
Gets the latest received message in the conversation.
- Returns
- The message instance.
◆ getMessage()
ChatMessage io.agora.chat.Conversation.getMessage |
( |
String | messageId, |
|
|
boolean | markAsRead ) |
Gets the message with message ID.
The SDK first retrieves the message from the memory. If no message is found, the SDK will retrieve it from the local database and load it.
- Parameters
-
messageId | The message ID. |
markAsRead | Whether to mark the retrieved message as read.
|
- Returns
- message The retrieved message instance.
◆ getMessageAttachmentPath()
String io.agora.chat.Conversation.getMessageAttachmentPath |
( |
| ) |
|
Gets the path to save attachments in the conversation.
Before clearing conversation data, you can call this method to check the path to save attachments related to the conversation. If necessary, implement exception protection.
- Returns
- The path to save attachments in the conversation.
◆ getPinnedTime()
long io.agora.chat.Conversation.getPinnedTime |
( |
| ) |
|
Gets the time when the conversation is pinned.
- Returns
- The UNIX timestamp when the conversation is pinned. The unit is millisecond. This value is
0
when the conversation is not pinned.
◆ getType()
Gets the conversation type.
- Returns
- The conversation type.
◆ getUnreadMsgCount()
int io.agora.chat.Conversation.getUnreadMsgCount |
( |
| ) |
|
Gets the number of unread messages in the conversation.
- Returns
- The unread message count in the conversation.
◆ insertMessage()
boolean io.agora.chat.Conversation.insertMessage |
( |
ChatMessage | msg | ) |
|
Inserts a message to the conversation in the local database。
To insert the message correctly, ensure that the conversation ID of the message is the same as that of the conversation.
The message will be inserted based on the Unix timestamp included in it. Upon message insertion, the SDK will automatically update attributes of the conversation, including latestMessage
.
- Parameters
-
◆ isChatThread()
boolean io.agora.chat.Conversation.isChatThread |
( |
| ) |
|
Checks whether the current conversation is a thread conversation.
- Returns
- Whether the conversation is a chat thread conversation.
◆ isGroup()
boolean io.agora.chat.Conversation.isGroup |
( |
| ) |
|
Checks whether it is a group conversation or a chat room conversation, or a conversation of another type.
- Returns
- Whether it is a group conversation or a chat room conversation, or a conversation of another type.
true
: It is a group conversation or a chat room conversation.
false
: It is not a group conversation or a chat room conversation.
◆ isPinned()
boolean io.agora.chat.Conversation.isPinned |
( |
| ) |
|
Checks whether the conversation is pinned.
- Returns
- Whether the conversation is pinned.
true
: Yes.
false
: No. The conversation is unpinned.
◆ loadMoreMsgFromDB() [1/2]
List< ChatMessage > io.agora.chat.Conversation.loadMoreMsgFromDB |
( |
String | startMsgId, |
|
|
int | pageSize ) |
Loads messages from the local database.
The loaded messages will be put in the conversation in the memory according to the timestamp in them and will be returned when you call getAllMessages()
.
- Parameters
-
startMsgId | The starting message ID for query. The SDK loads messages, starting from the specified one, in the descending order of the timestamp included in them. If this parameter is set as null or an empty string, the SDK retrieves messages, from the latest one, according to the descending order of the timestamp included in them. |
pageSize | The number of messages that you expect to get on each page. The value range is [1,400]. |
- Returns
- The list of retrieved messages (excluding the one with the starting ID).
◆ loadMoreMsgFromDB() [2/2]
Loads the messages from the local database, starting from a specific message ID.
The loaded messages will be put in the conversation in the memory according to the timestamp included in them.
- Parameters
-
startMsgId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, from the specified one, according to the message search direction. If this parameter is set as nil , the SDK retrieves messages according to the search direction while ignoring this parameter.
- If
direction is set as UP , the SDK retrieves messages, starting from the latest one, in the descending order of the timestamp included in them.
- If
direction is set as DOWN , the SDK retrieves messages, starting from the oldest one, in the ascending order of the timestamp included in them.
|
pageSize | The number of messages that you expect to get on each page. The value range is [1,400]. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
- Returns
- The list of retrieved messages (excluding the one with the starting ID).
◆ markAllMessagesAsRead()
void io.agora.chat.Conversation.markAllMessagesAsRead |
( |
| ) |
|
Marks all unread messages as read.
◆ markMessageAsRead()
void io.agora.chat.Conversation.markMessageAsRead |
( |
String | messageId | ) |
|
◆ marks()
Set< EMMarkType > io.agora.chat.Conversation.marks |
( |
| ) |
|
Gets all marks for the conversation.
- Returns
- All marks for the conversation.
◆ msgType2ConversationType()
static ConversationType io.agora.chat.Conversation.msgType2ConversationType |
( |
String | id, |
|
|
ChatMessage.ChatType | type ) |
|
static |
Converts a message type to a conversation type.
- Parameters
-
id | The message ID. |
type | The message type. |
- Returns
- The conversation type.
◆ pinnedMessages()
List< ChatMessage > io.agora.chat.Conversation.pinnedMessages |
( |
| ) |
|
Gets the list of pinned messages in a local conversation.
- Returns
- All pinned messages in the conversation.
◆ pushRemindType()
PushManager.PushRemindType io.agora.chat.Conversation.pushRemindType |
( |
| ) |
|
Gets the push reminder type of the conversation.
- Returns
- The push reminder type of the conversation.
◆ removeMessage()
void io.agora.chat.Conversation.removeMessage |
( |
String | messageId | ) |
|
Deletes a message in the local database.
- Parameters
-
messageId | The ID of the message to delete. |
◆ removeMessages()
boolean io.agora.chat.Conversation.removeMessages |
( |
long | startTime, |
|
|
long | endTime ) |
Deletes messages sent or received in a certain period from the local database.
- Parameters
-
startTime | The starting Unix timestamp for message deletion. The unit is millisecond. |
endTime | The ending Unix timestamp for message deletion. The unit is millisecond. |
- Returns
- Whether the message deletion succeeds:
- If the operation succeeds, the SDK returns
true
.
- If the operation fails, the SDK returns
false
.
◆ removeMessagesFromServer() [1/2]
void io.agora.chat.Conversation.removeMessagesFromServer |
( |
List< String > | msgIdList, |
|
|
CallBack | callBack ) |
Deletes historical messages from the server unidirectionally by message ID.
- Parameters
-
msgIdList | The list of IDs of messages to be deleted from the server unidirectionally. |
callBack | The result callback which contains the error information if the method fails. See CallBack . |
◆ removeMessagesFromServer() [2/2]
void io.agora.chat.Conversation.removeMessagesFromServer |
( |
long | beforeTimeStamp, |
|
|
CallBack | callBack ) |
Deletes historical messages from the server unidirectionally by timestamp.
- Parameters
-
beforeTimeStamp | The starting UNIX timestamp for unidirectional message deletion. The unit is millisecond. After the timestamp is set, this method deletes messages that are received by the server before the specified timestamp. |
callBack | The result callback which contains the error information if the method fails. See CallBack . |
◆ searchCustomMsgFromDB()
List< ChatMessage > io.agora.chat.Conversation.searchCustomMsgFromDB |
( |
String | keywords, |
|
|
long | timeStamp, |
|
|
int | maxCount, |
|
|
String | from, |
|
|
SearchDirection | direction ) |
Gets custom messages with keywords that the specified user sends in the conversation.
Note: Be cautious about memory usage when the maxCount is large.
- Parameters
-
keywords | The keywords for search. |
timeStamp | TThe starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as a negative value, the SDK retrieves from the current time. |
maxCount | The maximum number of messages to retrieve. The value range is [1,400]. |
from | The user ID of the message sender. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation, with no restriction on the message sender. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
- Returns
- The list of retrieved messages (excluding the one with the starting timestamp).
◆ searchMsgFromDB() [1/6]
List< ChatMessage > io.agora.chat.Conversation.searchMsgFromDB |
( |
long | startTimeStamp, |
|
|
long | endTimeStamp, |
|
|
int | maxCount ) |
Gets a certain quantity of messages sent or received in a certain period from the local database.
- Parameters
-
- Returns
- The list of retrieved messages (excluding the ones with the starting timestamp and ending timestamp).
◆ searchMsgFromDB() [2/6]
Retrieves messages in the local database based on the Unix timestamp included in them.
- Parameters
-
timeStamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them. |
maxCount | The maximum number of message to retrieve each time. The value range is [1,400]. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
- Returns
- The list of retrieved messages (excluding the one with the starting timestamp).
◆ searchMsgFromDB() [3/6]
List< ChatMessage > io.agora.chat.Conversation.searchMsgFromDB |
( |
Set< Type > | types, |
|
|
long | timeStamp, |
|
|
int | maxCount, |
|
|
String | from, |
|
|
SearchDirection | direction ) |
Gets messages of multiple types that a specified user sends in the conversation.
- Parameters
-
types | The message types. See Type . |
timeStamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as a negative value, the SDK retrieves from the latest message. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The user ID of the message sender. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation, with no restriction on the message sender. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
- Returns
- The list of retrieved messages (excluding the one with the starting timestamp).
◆ searchMsgFromDB() [4/6]
List< ChatMessage > io.agora.chat.Conversation.searchMsgFromDB |
( |
String | keywords, |
|
|
long | timeStamp, |
|
|
int | maxCount, |
|
|
String | from, |
|
|
SearchDirection | direction ) |
Gets messages with keywords that the specified user sends in the conversation.
- Parameters
-
keywords | The keywords for query. |
timeStamp | The starting Unix timestamp for search. The unit is millisecond. If this parameter is set as a negative value, the SDK retrieves from the current time. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The user ID of the message sender. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation, with no restriction on the message sender. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
- Returns
- The list of retrieved messages (excluding the one with the starting timestamp).
◆ searchMsgFromDB() [5/6]
Gets messages with keywords that the specified user sends in the conversation.
- Parameters
-
keywords | The keywords for query. |
timeStamp | The starting Unix timestamp for search. The unit is millisecond. If this parameter is set as a negative value, the SDK retrieves from the current time. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. If you set this parameter to 0 or less, the SDK gets one message from the local database. |
from | The user ID of the message sender. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation, with no restriction on the message sender. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
searchScope | The scope of search message. See ChatMessageSearchScope . |
- Returns
- The list of retrieved messages (excluding the one with the starting timestamp).
◆ searchMsgFromDB() [6/6]
Gets messages of a certain type that a specified user sends in the conversation.
- Parameters
-
type | The message type. See Type . |
timeStamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as a negative value, the SDK retrieves from the latest message. |
maxCount | The maximum number of messages to retrieve each time. The value range is [1,400]. |
from | The user ID of the message sender. If this parameter is set to null or an empty string, the SDK searches for messages in the entire conversation, with no restriction on the message sender. |
direction | The message search direction. See SearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN : The SDK retrieves messages in the ascending order of the timestamp included in them.
|
- Returns
- The list of retrieved messages (excluding the one with the starting timestamp).
◆ setExtField()
void io.agora.chat.Conversation.setExtField |
( |
String | ext | ) |
|
Sets the extension field of the conversation.
The extension field is only stored in the local database, but not synchronized to the server.
The extension field of a chat thread conversation is not saved in the local database.
- Parameters
-
ext | The extension field of the conversation. |
◆ updateMessage()
boolean io.agora.chat.Conversation.updateMessage |
( |
ChatMessage | msg | ) |
|
Updates a message in the local database.
After you update a message, the message ID remains unchanged and the SDK automatically updates attributes of the conversation, like latestMessage
.
- Parameters
-
msg | The message to update. |
The documentation for this class was generated from the following file:
- io/agora/chat/Conversation.java