EMConversation

EMConversation

new EMConversation(conversation)

Source:
EMConversation constructor.
Parameters:
Name Type Description
conversation Object

Methods

appendMessage(message) → {Bool}

Source:
Append a message to the last of conversation. Note: It's user's responsibility to confirm inserted message belongs to the conversation. 在消息末尾添加
Parameters:
Name Type Description
message EMMessage 消息对象
Returns:
添加消息结果
Type
Bool

clearAllMessages() → {Bool}

Source:
Clear all messages belong to the the conversation(include DB and memory cache).
Returns:
删除所有消息结果
Type
Bool

conversationId() → {String}

Source:
Get conversation id. Note: For a single chat conversation, it's remote peer's user name, for a group chat conversation, it's group id.
Returns:
会话ID
Type
String

conversationType() → {Number}

Source:
Get conversation type.
Returns:
会话类型
Type
Number

extField() → {String}

Source:
Get conversation extend attribute.
Returns:
返回会话扩展属性
Type
String

insertMessage(message) → {Bool}

Source:
Insert a message to DB. Note: It's user's responsibility to confirm inserted message belongs to the conversation. 在指定时间插入消息
Parameters:
Name Type Description
message EMMessage 消息对象
Returns:
插入消息结果
Type
Bool

lastSyncedMsgId() → {String}

Source:
Get conversation last sync roam key. if don't have, return empty string.
Returns:
返回最新的同步消息ID
Type
String

latestMessage() → {EMMessage}

Source:
Get latest message of conversation.
Returns:
返回最新消息对象
Type
EMMessage

latestMessageFromOthers() → {EMMessage}

Source:
Get received latest message of conversation.
Returns:
返回最新接收的消息对象
Type
EMMessage

loadMessage() → {EMMessage}

Source:
Load a message(Will load message from DB if not exist in cache).
Parameters:
Name Type Description
msgId. String 消息ID
Returns:
返回消息对象
Type
EMMessage

loadMoreMessagesBetweenTime(startTimeStamp, endTimeStamp, maxCount) → {Array}

Source:
Load messages from DB. Note: To avoid occupy too much memory, user should limit the max messages count to load. The result will be sorted by ASC. The trailing position resident last arrived message;
Parameters:
Name Type Description
startTimeStamp Number 起始时间
endTimeStamp Number 结束时间
maxCount Number 最大消息计数
Returns:
EMMessage array list.
Type
Array

loadMoreMessagesByKeyWords(keywords, timeStamp, count, from, direction) → {Array}

Source:
Load specified number of messages before the timestamp and contains the specified keywords from DB. Note: The result will be sorted by ASC.
Parameters:
Name Type Description
keywords String Message contains keywords, will ignore it if it's empty.
timeStamp Number the reference timestamp, milliseconds, will reference current time if timestamp is negative. default is -1.
count Number Message count to load, will load all messages meeet the conditions if count is negative. default is -1.
from String Message sender, will ignore it if it's empty, default is empty.
direction Number Message search direction, default is UP(0).
Returns:
EMMessage array list.
Type
Array

loadMoreMessagesByMsgId(refMsgId, count, direction) → {Array}

Source:
Load specified number of messages from DB. Note: The return result will NOT include the reference message, and load message from the latest message if reference message id is empty. The result will be sorted by ASC. The trailing position resident last arrived message;
Parameters:
Name Type Description
refMsgId String 起始消息ID
count Number 要加载的消息计数
direction Number optional
Returns:
EMMessage array list.
Type
Array

loadMoreMessagesByTime(timeStamp, count, direction) → {Array}

Source:
Load specified number of messages before the timestamp from DB. Note: The result will be sorted by ASC.
Parameters:
Name Type Description
timeStamp Number The reference timestamp
count Number Message count to load
direction Number optional. Message search direction
Returns:
EMMessage array list.
Type
Array

loadMoreMessagesByType(type, timeStamp, count, from, direction) → {Array}

Source:
Load specified number of messages before the timestamp and with the specified type from DB. Note: The result will be sorted by ASC.
Parameters:
Name Type Description
type Number Message type to load.
timeStamp Number optional. The reference timestamp, milliseconds, will reference current time if timestamp is negative. default is -1.
count Number optional. Message count to load, will load all messages meeet the conditions if count is negative. default is -1.
from String optional. Message sender, will ignore it if it's empty. default is empty.
direction Number optional. Message search direction. default is UP(0).
Returns:
EMMessage array list.
Type
Array

markAllMessagesAsRead(isRead) → {Bool}

Source:
Change all messages's read status.
Parameters:
Name Type Description
isRead Bool 消息已读状态
Returns:
设置结果
Type
Bool

markMessageAsRead(msgId, isRead) → {Bool}

Source:
Change message's read status. Note: It's user's responsibility to confirm changed message belongs to the conversation.
Parameters:
Name Type Description
msgId String 消息ID
isRead Bool 消息已读状态
Returns:
设置结果
Type
Bool

messagesCount() → {Number}

Source:
Get the total messages count of conversation.
Returns:
返回消息计数
Type
Number

removeMessage(message) → {Bool}

Source:
Remove a message from DB and cache. Note: It's user's responsibility to confirm removed message belongs to the conversation. Better to use message to remove message instead of message id.
Parameters:
Name Type Description
message EMMessage | String EMMessage is the message to remove, String is message Id.
Returns:
删除消息结果
Type
Bool

setExtField(ext)

Source:
Set conversation extend attribute.
Parameters:
Name Type Description
ext String 设置的会话扩展属性

unreadMessagesCount() → {Number}

Source:
Get unread messages count of conversation.
Returns:
返回未读消息计数
Type
Number

updateMessage(message) → {Bool}

Source:
Append a message to the last of conversation. It's user's responsibility to confirm updated message belongs to the conversation, and user should NOT change a message's id. 修改制定消息
Parameters:
Name Type Description
message EMMessage 消息对象
Returns:
修改消息结果
Type
Bool