Easemob Windows SDK
Public Types | Public Member Functions | Public Attributes | List of all members
easemob::EMConversation Class Reference
Inheritance diagram for easemob::EMConversation:
Inheritance graph
Collaboration diagram for easemob::EMConversation:
Collaboration graph

Public Types

enum  EMConversationType {
  CHAT, GROUPCHAT, CHATROOM, DISCUSSIONGROUP,
  HELPDESK
}
 
enum  EMMessageSearchDirection { UP, DOWN }
 

Public Member Functions

virtual ~EMConversation ()
 Conversation's destructor. More...
 
const std::string & conversationId () const
 Get conversation id. More...
 
EMConversationType conversationType () const
 Get conversation type. More...
 
bool removeMessage (const std::string &msgId)
 Remove a message from DB and cache. More...
 
bool removeMessage (const EMMessagePtr msg)
 Remove a message from DB and cache. More...
 
bool insertMessage (const EMMessagePtr msg)
 Insert a message to DB. More...
 
bool appendMessage (const EMMessagePtr msg)
 Append a message to the last of conversation. More...
 
bool updateMessage (const EMMessagePtr msg)
 Update message's memory change to DB. More...
 
bool clearAllMessages ()
 Clear all messages belong to the the conversation(include DB and memory cache). More...
 
bool markMessageAsRead (const std::string &msgId, bool isRead=true)
 Change message's read status. More...
 
bool markAllMessagesAsRead (bool isRead=true)
 Change all messages's read status. More...
 
int unreadMessagesCount () const
 Get unread messages count of conversation. More...
 
int messagesCount () const
 Get the total messages count of conversation. More...
 
EMMessagePtr loadMessage (const std::string &msgId) const
 Load a message(Will load message from DB if not exist in cache). More...
 
EMMessagePtr latestMessage () const
 Get latest message of conversation. More...
 
EMMessagePtr latestMessageFromOthers () const
 Get received latest message of conversation. More...
 
EMMessageList loadMoreMessages (const std::string &refMsgId, int count, EMMessageSearchDirection direction=UP)
 Load specified number of messages from DB. More...
 
EMMessageList loadMoreMessages (int64_t timeStamp, int count, EMMessageSearchDirection direction=UP)
 Load specified number of messages before the timestamp from DB. More...
 
EMMessageList loadMoreMessages (EMMessageBody::EMMessageBodyType type, int64_t timeStamp=-1, int count=-1, const std::string &from="", EMMessageSearchDirection direction=UP)
 Load specified number of messages before the timestamp and with the specified type from DB. More...
 
EMMessageList loadMoreMessages (const std::string &keywords, int64_t timeStamp=-1, int count=-1, const std::string &from="", EMMessageSearchDirection direction=UP)
 Load specified number of messages before the timestamp and contains the specified keywords from DB. More...
 
EMMessageList loadMoreMessages (int64_t startTimeStamp, int64_t endTimeStamp, int maxCount)
 Load messages from DB. More...
 
const std::string & extField () const
 Get conversation extend attribute. More...
 
bool setExtField (const std::string &ext)
 Set conversation extend attribute. More...
 
- Public Member Functions inherited from easemob::EMBaseObject
template<typename T >
T * cast ()
 

Public Attributes

friend EMConversationManager
 
friend EMChatManager
 
friend EMDatabase
 

Member Enumeration Documentation

§ EMConversationType

enum easemob::EMConversation::EMConversationType

Conversation type.

§ EMMessageSearchDirection

enum easemob::EMConversation::EMMessageSearchDirection

Message search direction.

Constructor & Destructor Documentation

§ ~EMConversation()

virtual easemob::EMConversation::~EMConversation ( )
virtual

Conversation's destructor.

Parameters
NA
Returns
NA

Member Function Documentation

§ appendMessage()

bool easemob::EMConversation::appendMessage ( const EMMessagePtr  msg)

Append a message to the last of conversation.

Note: It's user's responsibility to confirm inserted message belongs to the conversation.

Parameters
Themessage to append.
Returns
Return false if message can't insert to DB(e.g. has duplicate message with the same message id or user not login).

§ clearAllMessages()

bool easemob::EMConversation::clearAllMessages ( )

Clear all messages belong to the the conversation(include DB and memory cache).

Parameters
NA
Returns
Return false if can't clear the messages.

§ conversationId()

const std::string& easemob::EMConversation::conversationId ( ) const

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.

Parameters
NA
Returns
The conversation id.

§ conversationType()

EMConversationType easemob::EMConversation::conversationType ( ) const

Get conversation type.

Parameters
NA
Returns
The conversation type.

§ extField()

const std::string& easemob::EMConversation::extField ( ) const

Get conversation extend attribute.

Parameters
NA
Returns
The extend attribute.

§ insertMessage()

bool easemob::EMConversation::insertMessage ( const EMMessagePtr  msg)

Insert a message to DB.

Note: It's user's responsibility to confirm inserted message belongs to the conversation.

Parameters
Themessage to insert.
Returns
Return false if message can't insert to DB(e.g. has duplicate message with the same message id or user not login).

§ latestMessage()

EMMessagePtr easemob::EMConversation::latestMessage ( ) const

Get latest message of conversation.

Parameters
NA
Returns
The latest message.

§ latestMessageFromOthers()

EMMessagePtr easemob::EMConversation::latestMessageFromOthers ( ) const

Get received latest message of conversation.

Parameters
NA
Returns
The received latest message.

§ loadMessage()

EMMessagePtr easemob::EMConversation::loadMessage ( const std::string &  msgId) const

Load a message(Will load message from DB if not exist in cache).

Parameters
Themessage id
Returns
The loaded message.

§ loadMoreMessages() [1/5]

EMMessageList easemob::EMConversation::loadMoreMessages ( const std::string &  refMsgId,
int  count,
EMMessageSearchDirection  direction = UP 
)

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
Thereference messages's id
Messagecount to load
Messagesearch direction
Returns
The loaded messages list.

§ loadMoreMessages() [2/5]

EMMessageList easemob::EMConversation::loadMoreMessages ( int64_t  timeStamp,
int  count,
EMMessageSearchDirection  direction = UP 
)

Load specified number of messages before the timestamp from DB.

Note: The result will be sorted by ASC.

Parameters
Thereference timestamp
Messagecount to load
Messagesearch direction
Returns
The loaded messages list.

§ loadMoreMessages() [3/5]

EMMessageList easemob::EMConversation::loadMoreMessages ( EMMessageBody::EMMessageBodyType  type,
int64_t  timeStamp = -1,
int  count = -1,
const std::string &  from = "",
EMMessageSearchDirection  direction = UP 
)

Load specified number of messages before the timestamp and with the specified type from DB.

Note: The result will be sorted by ASC.

Parameters
Messagetype to load
Thereference timestamp, milliseconds, will reference current time if timestamp is negative
Messagecount to load, will load all messages meeet the conditions if count is negative
Messagesender, will ignore it if it's empty
Messagesearch direction
Returns
The loaded messages list.

§ loadMoreMessages() [4/5]

EMMessageList easemob::EMConversation::loadMoreMessages ( const std::string &  keywords,
int64_t  timeStamp = -1,
int  count = -1,
const std::string &  from = "",
EMMessageSearchDirection  direction = UP 
)

Load specified number of messages before the timestamp and contains the specified keywords from DB.

Note: The result will be sorted by ASC.

Parameters
Messagecontains keywords, will ignore it if it's empty
Thereference timestamp, milliseconds, will reference current time if timestamp is negative
Messagecount to load, will load all messages meeet the conditions if count is negative
Messagesender, will ignore it if it's empty
Messagesearch direction
Returns
The loaded messages list.

§ loadMoreMessages() [5/5]

EMMessageList easemob::EMConversation::loadMoreMessages ( int64_t  startTimeStamp,
int64_t  endTimeStamp,
int  maxCount 
)

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
Thestart time timestamp
Theend time timestamp
Themax count of messages to load
Returns
The loaded messages list.

§ markAllMessagesAsRead()

bool easemob::EMConversation::markAllMessagesAsRead ( bool  isRead = true)

Change all messages's read status.

Parameters
NA
Returns
Return false if can't change read status.

§ markMessageAsRead()

bool easemob::EMConversation::markMessageAsRead ( const std::string &  msgId,
bool  isRead = true 
)

Change message's read status.

Note: It's user's responsibility to confirm changed message belongs to the conversation.

Parameters
Themessage to change.
Returns
Return false if message can't insert to DB(e.g. DB operation failed or read status doesn't need to change).

§ messagesCount()

int easemob::EMConversation::messagesCount ( ) const

Get the total messages count of conversation.

Parameters
NA
Returns
The total messages count.

§ removeMessage() [1/2]

bool easemob::EMConversation::removeMessage ( const std::string &  msgId)

Remove a message from DB and cache.

Note: It's user's responsibility to confirm removed message belongs to the conversation.

Parameters
Themessage id
Returns
Return false if message isn't exist in DB.

§ removeMessage() [2/2]

bool easemob::EMConversation::removeMessage ( const EMMessagePtr  msg)

Remove a message from DB and cache.

Note: It's better to use this method to remove a message, and it's user's responsibility to confirm removed message belongs to the conversation.

Parameters
Themessage to remove
Returns
Return false if message isn't exist in DB.

§ setExtField()

bool easemob::EMConversation::setExtField ( const std::string &  ext)

Set conversation extend attribute.

Parameters
Theextend attribute.
Returns
Return false if set extend attribute failed.

§ unreadMessagesCount()

int easemob::EMConversation::unreadMessagesCount ( ) const

Get unread messages count of conversation.

Parameters
NA
Returns
The unread messages count.

§ updateMessage()

bool easemob::EMConversation::updateMessage ( const EMMessagePtr  msg)

Update message's memory change to DB.

Note: It's user's responsibility to confirm updated message belongs to the conversation, and user should NOT change a message's id.

Parameters
Themessage to remove
Returns
Return false if can't update message.

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