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

Public Types

enum  EMChatType { SINGLE, GROUP, CHATROOM }
 
enum  EMMessageStatus { NEW, DELIVERING, SUCCESS, FAIL }
 
enum  EMMessageDirection { SEND, RECEIVE }
 

Public Member Functions

virtual ~EMMessage ()
 Class destructor. More...
 
const std::string & msgId ()
 Get message id. More...
 
void setMsgId (const std::string &)
 Set message id. More...
 
const std::string & from ()
 Get message sender. More...
 
void setFrom (const std::string &)
 Set message sender. More...
 
const std::string & to ()
 Get message receiver. More...
 
void setTo (const std::string &)
 Set message receiver. More...
 
const std::string & conversationId ()
 Get conversation id. More...
 
void setConversationId (const std::string &)
 Set message's conversation id. More...
 
EMMessageStatus status ()
 Get message status. More...
 
void setStatus (EMMessageStatus)
 Set message's status. More...
 
EMChatType chatType ()
 Get message chat type. More...
 
void setChatType (EMChatType)
 Set message's chat type. More...
 
EMMessageDirection msgDirection ()
 Get message direction. More...
 
void setMsgDirection (EMMessageDirection)
 Set message's direction. More...
 
bool isRead ()
 Get message if has read status. More...
 
void setIsRead (bool isRead)
 Set message's read status. More...
 
bool isListened ()
 Get message if has listened status. More...
 
void setIsListened (bool isListened)
 Set message's listened status. More...
 
bool isReadAcked ()
 Get message read ack status. More...
 
void setIsReadAcked (bool)
 Set message's read ack status. More...
 
bool isDeliverAcked ()
 Get message delivering status. More...
 
void setIsDeliverAcked (bool)
 Set message's delivery ack status. More...
 
bool isOffline ()
 Get message offline status. More...
 
void setIsOffline (bool)
 Set message's offline status. More...
 
int64_t timestamp ()
 Get message timestamp(server time). More...
 
void setTimestamp (int64_t)
 Set message's timestamp. More...
 
int64_t localTime ()
 Get message's local time. More...
 
void setLocalTime (int64_t)
 Set message's local time. More...
 
std::vector< EMMessageBodyPtr > bodies ()
 Get message body list. More...
 
void clearBodies ()
 Clear all bodies. More...
 
void addBody (const EMMessageBodyPtr &body)
 Add a body to message. More...
 
template<typename T >
void setAttribute (const std::string &attribute, const T &value)
 Add a extend attribute to message. More...
 
template<typename T >
bool getAttribute (const std::string &attribute, T &value)
 Get extend attribute of message. More...
 
void removeAttribute (const std::string &attribute)
 Remove a attribute from message. More...
 
void clearAttributes ()
 Remove all attributes from message. More...
 
std::map< std::string, std::shared_ptr< EMAttributeValue > > ext ()
 Get all attributes from message. More...
 
EMCallbackPtr callback ()
 Get message's callback to notify status change. More...
 
void setCallback (EMCallbackPtr)
 Set message's callback to notify status change. More...
 
void setProgress (float percent)
 
float getProgress ()
 
- Public Member Functions inherited from easemob::EMBaseObject
template<typename T >
T * cast ()
 

Static Public Member Functions

static std::shared_ptr< EMMessagecreateReceiveMessage (const std::string &from, const std::string &to, const EMMessageBodyPtr &body, EMChatType=SINGLE, const std::string &msgId="")
 Create a received message. More...
 
static std::shared_ptr< EMMessagecreateSendMessage (const std::string &from, const std::string &to, const EMMessageBodyPtr &body, EMChatType=SINGLE)
 Create a send message. More...
 

Friends

class EMMessagePrivate
 
class EMMessageEncoder
 

Member Enumeration Documentation

§ EMChatType

enum easemob::EMMessage::EMChatType

Message chat type.

§ EMMessageStatus

enum easemob::EMMessage::EMMessageStatus

Message status.

Constructor & Destructor Documentation

§ ~EMMessage()

virtual easemob::EMMessage::~EMMessage ( )
virtual

Class destructor.

Parameters
NA
Returns
NA

Member Function Documentation

§ addBody()

void easemob::EMMessage::addBody ( const EMMessageBodyPtr &  body)

Add a body to message.

Note: The ownership of the body will be transfered, user must NOT release it.

Parameters
Amessage body.
Returns
NA

§ bodies()

std::vector<EMMessageBodyPtr> easemob::EMMessage::bodies ( )

Get message body list.

Parameters
NA
Returns
The message body list.

§ callback()

EMCallbackPtr easemob::EMMessage::callback ( )

Get message's callback to notify status change.

Parameters
NA
Returns
The callback.

§ chatType()

EMChatType easemob::EMMessage::chatType ( )

Get message chat type.

Parameters
NA
Returns
The message chat type.

§ clearAttributes()

void easemob::EMMessage::clearAttributes ( )

Remove all attributes from message.

Parameters
NA
Returns
NA

§ clearBodies()

void easemob::EMMessage::clearBodies ( )

Clear all bodies.

Parameters
NA
Returns
NA.

§ conversationId()

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

Get conversation id.

Parameters
NA
Returns
The conversation id.

§ createReceiveMessage()

static std::shared_ptr<EMMessage> easemob::EMMessage::createReceiveMessage ( const std::string &  from,
const std::string &  to,
const EMMessageBodyPtr &  body,
EMChatType  = SINGLE,
const std::string &  msgId = "" 
)
static

Create a received message.

Parameters
Themessage sender.
Themessage receiver.
Themessage body.
Themessage chat type.
Themessage id.
Returns
A message instance.

§ createSendMessage()

static std::shared_ptr<EMMessage> easemob::EMMessage::createSendMessage ( const std::string &  from,
const std::string &  to,
const EMMessageBodyPtr &  body,
EMChatType  = SINGLE 
)
static

Create a send message.

Parameters
Themessage sender.
Themessage receiver.
Themessage body.
Themessage chat type.
Returns
A message instance.

§ ext()

std::map<std::string, std::shared_ptr<EMAttributeValue> > easemob::EMMessage::ext ( )

Get all attributes from message.

Parameters
NA
Returns
Attributes map.

§ from()

const std::string& easemob::EMMessage::from ( )

Get message sender.

Parameters
NA
Returns
The message sender.

§ getAttribute()

template<typename T >
bool easemob::EMMessage::getAttribute ( const std::string &  attribute,
T &  value 
)

Get extend attribute of message.

Note: Supported types: bool, int, unsigned int, int64_t and string.

Parameters
Theattrubute key.
Theattrubute value, it's a out argument.
Returns
Return false if attribute not exist or attribute type is wrong.

§ isDeliverAcked()

bool easemob::EMMessage::isDeliverAcked ( )

Get message delivering status.

Note: For receiver, it indicates whether has sent delivering successed ack, and for sender, it indicates whether has received delivering successed ack.

Parameters
NA
Returns
The message delivering status.

§ isListened()

bool easemob::EMMessage::isListened ( )

Get message if has listened status.

Parameters
NA
Returns
The message listened status.

§ isOffline()

bool easemob::EMMessage::isOffline ( )

Get message offline status.

Parameters
NA
Returns
The message offline status.

§ isRead()

bool easemob::EMMessage::isRead ( )

Get message if has read status.

Parameters
NA
Returns
The message read status.

§ isReadAcked()

bool easemob::EMMessage::isReadAcked ( )

Get message read ack status.

Note: For receiver, it indicates whether has sent read ack, and for sender, it indicates whether has received read ack.

Parameters
NA
Returns
The message read ack status.

§ localTime()

int64_t easemob::EMMessage::localTime ( )

Get message's local time.

Parameters
NA
Returns
The server time.

§ msgDirection()

EMMessageDirection easemob::EMMessage::msgDirection ( )

Get message direction.

Parameters
NA
Returns
The message direction.

§ msgId()

const std::string& easemob::EMMessage::msgId ( )

Get message id.

Parameters
NA
Returns
The message id.

§ removeAttribute()

void easemob::EMMessage::removeAttribute ( const std::string &  attribute)

Remove a attribute from message.

Parameters
Theattribute key.
Returns
NA

§ setAttribute()

template<typename T >
void easemob::EMMessage::setAttribute ( const std::string &  attribute,
const T &  value 
)

Add a extend attribute to message.

Note: Supported types: bool, int32_t, uint32_t, int64_t, double, string and EMJsonString. If the attribute has already existed, it will be replaced.

Parameters
Theattrubute key.
Theattrubute value.
Returns
NA

§ setCallback()

void easemob::EMMessage::setCallback ( EMCallbackPtr  )

Set message's callback to notify status change.

Parameters
Thecallback.
Returns
NA.

§ setChatType()

void easemob::EMMessage::setChatType ( EMChatType  )

Set message's chat type.

Note: User should NOT change message's chat type after receive or send a message.

Parameters
Thenew conversation id.
Returns
NA.

§ setConversationId()

void easemob::EMMessage::setConversationId ( const std::string &  )

Set message's conversation id.

Note: User should NOT change message's conversation id after receive or send a message.

Parameters
Thenew conversation id.
Returns
NA.

§ setFrom()

void easemob::EMMessage::setFrom ( const std::string &  )

Set message sender.

Parameters
Thenew message sender.
Returns
NA.

§ setIsDeliverAcked()

void easemob::EMMessage::setIsDeliverAcked ( bool  )

Set message's delivery ack status.

Note: User should NOT change message's delivery ack status directly.

Parameters
Thenew message delivery ack status.
Returns
NA.

§ setIsListened()

void easemob::EMMessage::setIsListened ( bool  isListened)

Set message's listened status.

Note: User should NOT change message's listened status directly.

Parameters
Thenew message listened status.
Returns
NA.

§ setIsOffline()

void easemob::EMMessage::setIsOffline ( bool  )

Set message's offline status.

Note: User should never change message's offline status.

Parameters
Thenew message offline status.
Returns
NA.

§ setIsRead()

void easemob::EMMessage::setIsRead ( bool  isRead)

Set message's read status.

Note: User should NOT change message's read status directly.

Parameters
Thenew message read status.
Returns
NA.

§ setIsReadAcked()

void easemob::EMMessage::setIsReadAcked ( bool  )

Set message's read ack status.

Note: User should NOT change message's read ack status directly.

Parameters
Thenew message read ack status.
Returns
NA.

§ setLocalTime()

void easemob::EMMessage::setLocalTime ( int64_t  )

Set message's local time.

Note: User should NOT change message's server time.

Parameters
Thenew message server time.
Returns
NA.

§ setMsgDirection()

void easemob::EMMessage::setMsgDirection ( EMMessageDirection  )

Set message's direction.

Note: User should NOT change message's message direction after receive or send a message.

Parameters
NA
Returns
NA.

§ setMsgId()

void easemob::EMMessage::setMsgId ( const std::string &  )

Set message id.

Note: User should never change a message's id if you don't want to save as a new message.

Parameters
Thenew message id.
Returns
NA.

§ setStatus()

void easemob::EMMessage::setStatus ( EMMessageStatus  )

Set message's status.

Note: User should NOT change message's status directly.

Parameters
Thenew message status.
Returns
NA.

§ setTimestamp()

void easemob::EMMessage::setTimestamp ( int64_t  )

Set message's timestamp.

Note: User should NOT change message's timestamp.

Parameters
Thenew message timestamp.
Returns
NA.

§ setTo()

void easemob::EMMessage::setTo ( const std::string &  )

Set message receiver.

Parameters
Thenew message receiver.
Returns
NA.

§ status()

EMMessageStatus easemob::EMMessage::status ( )

Get message status.

Parameters
NA
Returns
The message status.

§ timestamp()

int64_t easemob::EMMessage::timestamp ( )

Get message timestamp(server time).

Parameters
NA
Returns
The message timestamp.

§ to()

const std::string& easemob::EMMessage::to ( )

Get message receiver.

Parameters
NA
Returns
The message receiver.

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