agora_chat_SDK
3.8.2
agorajavachatSDK
|
Inherits io.agora.chat.EMBase< T >.
Classes | |
enum | ConversationType |
class | MessageCache |
enum | SearchDirection |
Public Member Functions | |
String | conversationId () |
ConversationType | getType () |
int | getUnreadMsgCount () |
void | markAllMessagesAsRead () |
int | getAllMsgCount () |
List< ChatMessage > | loadMoreMsgFromDB (String startMsgId, int pageSize) |
List< ChatMessage > | searchMsgFromDB (long timeStamp, int maxCount, SearchDirection direction) |
List< ChatMessage > | searchMsgFromDB (ChatMessage.Type type, long timeStamp, int maxCount, String from, SearchDirection direction) |
List< ChatMessage > | searchMsgFromDB (String keywords, long timeStamp, int maxCount, String from, SearchDirection direction) |
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) |
List< ChatMessage > | loadMessages (List< String > msgIds) |
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 | isGroup () |
void | insertMessage (ChatMessage msg) |
void | appendMessage (ChatMessage msg) |
boolean | updateMessage (ChatMessage msg) |
String | getMessageAttachmentPath () |
Static Public Member Functions | |
static ConversationType | msgType2ConversationType (String id, ChatMessage.ChatType type) |
Conversation class, represent a conversation with a user/group/chat room and contains messages that are sent and received For example, Gets the number of unread messages from the conversation:
// ConversationId can be the other party id, the group id, or the chat room id Conversation conversation = ChatClient.getInstance().chatManager().getConversation(conversationId); int unread = conversation.getUnreadMsgCount();
void io.agora.chat.Conversation.appendMessage | ( | ChatMessage | 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. And the latestMessage and other properties of the session should be updated
msg | Message |
void io.agora.chat.Conversation.clear | ( | ) |
Clear messages in this conversation Which clear only memory messages, but will not clear local database Reduce memory consumption by clearing the memory cache when exiting a conversation
void io.agora.chat.Conversation.clearAllMessages | ( | ) |
Delete all messages of the conversation from memory cache and local database
String io.agora.chat.Conversation.conversationId | ( | ) |
Conversation ID For single chat,conversation ID is to chat user's name For group chat, conversation ID is group ID, different with group name 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<ChatMessage> io.agora.chat.Conversation.getAllMessages | ( | ) |
Get all message in local cache If empty, then get latest message from local database
int io.agora.chat.Conversation.getAllMsgCount | ( | ) |
Get all messages count in this conversation
String io.agora.chat.Conversation.getExtField | ( | ) |
Get conversation extension Extend field only stored in local database, not sync to network server
ChatMessage io.agora.chat.Conversation.getLastMessage | ( | ) |
Get last message from conversation The operation does not change the unread message count Get from cache, if empty, will load from database and put it in the cache
ChatMessage io.agora.chat.Conversation.getLatestMessageFromOthers | ( | ) |
Get received latest message from conversation
ChatMessage io.agora.chat.Conversation.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
messageId | Message id |
markAsRead | Whether to mark the message as read while getting it, if true, will mark the message as read and send read ack to server |
String io.agora.chat.Conversation.getMessageAttachmentPath | ( | ) |
Return conversation associated attachment path Which can be used to erase conversation related downloaded files from local storage. Not ensure the return path exists, please handle IOException when deleting directory
ConversationType io.agora.chat.Conversation.getType | ( | ) |
Get conversation type
int io.agora.chat.Conversation.getUnreadMsgCount | ( | ) |
Get unread message count
void io.agora.chat.Conversation.insertMessage | ( | ChatMessage | 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. And the latestMessage and other properties of the session should be updated
msg | Instance of Message |
boolean io.agora.chat.Conversation.isGroup | ( | ) |
Gets whether it is a group or chat room conversation
List<ChatMessage> io.agora.chat.Conversation.loadMessages | ( | List< String > | msgIds | ) |
Load messages, If those message not exists in memory in cache, will load message from database
msgIds | message ids to be loaded |
List<ChatMessage> io.agora.chat.Conversation.loadMoreMsgFromDB | ( | String | startMsgId, |
int | pageSize | ||
) |
Load more messages from database Load message from database by passing in parameters, which message id starting from param startMsgId, messages will also store in to current conversation's 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 io.agora.chat.Conversation.markAllMessagesAsRead | ( | ) |
Mark all messages as read
void io.agora.chat.Conversation.markMessageAsRead | ( | String | messageId | ) |
Mark the message as read by specified messageId To make the message read, you can also use ChatMessage#setUnread(boolean)
messageId | Message id |
|
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 |
type | Message type |
void io.agora.chat.Conversation.removeMessage | ( | String | messageId | ) |
Delete a message Note: Operates only on local data
messageId | message to be deleted |
List<ChatMessage> io.agora.chat.Conversation.searchCustomMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
SearchDirection | direction | ||
) |
Search custom messages from database based the parameters Note: Cautious about memory usage when the maxCount is large
keywords | The keywords in message. |
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
from | Who the message from, also can used to search in group |
List<ChatMessage> io.agora.chat.Conversation.searchMsgFromDB | ( | long | timeStamp, |
int | maxCount, | ||
SearchDirection | direction | ||
) |
Search message from database according the parameters Note: Cautious about memory usage when the maxCount is large
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
List<ChatMessage> io.agora.chat.Conversation.searchMsgFromDB | ( | ChatMessage.Type | type, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
SearchDirection | direction | ||
) |
Search message from database according the parameters Note: Cautious about memory usage when the maxCount is large
type | Message type, TXT、VOICE、IMAGE and so on |
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
from | Who the message from, also can used to search in group |
List<ChatMessage> io.agora.chat.Conversation.searchMsgFromDB | ( | String | keywords, |
long | timeStamp, | ||
int | maxCount, | ||
String | from, | ||
SearchDirection | direction | ||
) |
Search message from database based the parameters Note: Cautious about memory usage when the maxCount is large
keywords | The keywords in message. |
timeStamp | The timestamp for search |
maxCount | The max number of message to search |
from | Who the message from, also can used to search in group |
List<ChatMessage> io.agora.chat.Conversation.searchMsgFromDB | ( | long | startTimeStamp, |
long | endTimeStamp, | ||
int | maxCount | ||
) |
Search message from database based the parameters Note: Cautious about memory usage when the maxCount is large
startTimeStamp | Start timestamp for search in |
endTimeStamp | End timestamp for search |
maxCount | The max number of message to search |
void io.agora.chat.Conversation.setExtField | ( | String | ext | ) |
Set Conversation extension Extend field only stored in local database, not sync to network server
ext | Extension string |
boolean io.agora.chat.Conversation.updateMessage | ( | ChatMessage | msg | ) |
Update a message in local database Message id of the message cannot be updated. Latest Message of the conversation and other properties will be updated accordingly.
msg | Message |