EMMessage

EMMessage

new EMMessage(message)

Source:
EMMessage constructor.
Parameters:
Name Type Description
message Object

Methods

addBody(body) → {void}

Source:
Add a body to message.
Parameters:
Name Type Description
body EMMessageBody
Returns:
Type
void

bodies() → {Array}

Source:
Get message body list.
Returns:
message bodies list.
Type
Array

callback() → {EMCallback}

Source:
Get message's callback to notify status change.
Returns:
返回消息回调对象
Type
EMCallback

chatType() → {Number}

Source:
Get message chat type.
Returns:
返回聊天类型
Type
Number

clearAttributes() → {void}

Source:
Remove all attributes from message.
Returns:
Type
void

clearBodies() → {void}

Source:
Clear all bodies.
Returns:
Type
void

conversationId() → {String}

Source:
Get conversation id.
Returns:
返回消息的会话ID
Type
String

ext() → {Array}

Source:
Get all attributes from message.
Returns:
array contains obj, obj like { "attr" : "1", "value" : "1" }
Type
Array

from() → {String}

Source:
Get message sender.
Returns:
消息发送者
Type
String

getAttribute(attribute) → {Bool|Number|String}

Source:
Get extend attribute of message. Note: Supported types: Bool Number and String.
Parameters:
Name Type Description
attribute String 消息属性
Returns:
属性值
Type
Bool | Number | String

getJsonAttribute(attribute) → {Object}

Source:
Get extend attribute of json object.
Parameters:
Name Type Description
attribute String 消息属性
Returns:
属性的json字符串
Type
Object

getProgress() → {Number}

Source:
Get progress
Returns:
返回消息收发进度
Type
Number

isDeliverAcked() → {Bool}

Source:
Get message delivering status. Note: For receiver, it indicates whether has sent delivering succeed ack; and for sender, it indicates whether has received delivering succeed ack.
Returns:
返回消息发ack状态
Type
Bool

isListened() → {Bool}

Source:
Get message if has listened status.
Returns:
返回消息是否已接收
Type
Bool

isRead() → {Bool}

Source:
Get if message is read status.
Returns:
返回消息是否已读
Type
Bool

isReadAcked() → {Bool}

Source:
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.
Returns:
返回消息读ack状态
Type
Bool

localTime() → {Number}

Source:
Get message's local time.
Returns:
返回消息本地时间
Type
Number

msgDirection() → {Number}

Source:
Get message direction.
Returns:
返回消息收发方向,0为发,1为收
Type
Number

msgId() → {String}

Source:
Get message id.
Returns:
返回消息ID
Type
String

removeAttribute(attribute) → {void}

Source:
Remove a attribute from message by key.
Parameters:
Name Type Description
attribute String 消息属性
Returns:
Type
void

setAttribute(attribute, value) → {void}

Source:
Add a extend attribute to message. Note: Supported types: Bool Number and String.
Parameters:
Name Type Description
attribute String 消息属性
value Bool | Number | String 属性值
Returns:
Type
void

setCallback(callback) → {void}

Source:
Set message's callback to notify status change.
Parameters:
Name Type Description
callback EMCallback 消息回调对象
Returns:
Type
void

setChatType(status) → {void}

Source:
Set message's chat type. Note: User should NOT change message's chat type after receive or send a message. { SINGLE = 0, // One-to-one chat GROUP = 1, // Group chat CHATROOM = 2 // Chatroom chat }
Parameters:
Name Type Description
status Number 聊天类型
Returns:
Type
void

setConversationId(conversationId) → {void}

Source:
Set message's conversation id. Note: User should NOT change message's conversation id after received or sent a message.
Parameters:
Name Type Description
conversationId String 消息的会话ID
Returns:
Type
void

setFrom(from) → {void}

Source:
Set message sender.
Parameters:
Name Type Description
from String 消息发送者
Returns:
Type
void

setIsDeliverAcked(isDeliverAcked) → {void}

Source:
Set message's delivery ack status. Note: User should NOT change message's delivery ack status directly.
Parameters:
Name Type Description
isDeliverAcked Bool 消息发ack状态
Returns:
Type
void

setIsListened(isListened) → {void}

Source:
Set message's listened status. Note: User should NOT change message's listened status directly.
Parameters:
Name Type Description
isListened Bool 消息是否已接收
Returns:
Type
void

setIsRead(isRead) → {void}

Source:
Set if message is read status. Note: User should NOT change message's read status directly.
Parameters:
Name Type Description
isRead Bool 消息是否已读
Returns:
Type
void

setIsReadAcked(isRead) → {void}

Source:
Set message's read ack status. Note: User should NOT change message's read ack status directly.
Parameters:
Name Type Description
isRead Bool 消息读ack状态
Returns:
Type
void

setJsonAttribute(attribute, object) → {void}

Source:
Add a extend json object attribute to message.
Parameters:
Name Type Description
attribute String 消息属性
object Object 属性的json字符串
Returns:
Type
void

setLocalTime(timestamp) → {void}

Source:
Set message's local time. Note: User should NOT change message's server time.
Parameters:
Name Type Description
timestamp Number 返回消息本地时间
Returns:
Type
void

setMsgDirection(msgDirection) → {void}

Source:
Set message's direction. Note: User should NOT change message's message direction after received or sent a message. message direction. { SEND = 0, RECEIVE = 1 }
Parameters:
Name Type Description
msgDirection Number 消息收发方向,0为发,1为收
Returns:
Type
void

setMsgId(msgId) → {void}

Source:
Set message id. Note: User should never change a message's id if you don't want to save as a new message.
Parameters:
Name Type Description
msgId String 消息ID
Returns:
Type
void

setProgress(percent) → {void}

Source:
Set progress.
Parameters:
Name Type Description
percent Number 消息收发进度
Returns:
Type
void

setStatus(status) → {void}

Source:
Set message's status. Note: User should NOT change message's status directly. Message status. { NEW = 0, // New message DELIVERING = 1, // Message is delivering SUCCESS = 2, // Message is delivered successfully FAIL = 3 // Message delivering failed }
Parameters:
Name Type Description
status Number 消息状态
Returns:
Type
void

setTimestamp(timestamp) → {void}

Source:
Set message's timestamp. Note: User should NOT change message's timestamp.
Parameters:
Name Type Description
timestamp Number 返回消息服务器时间
Returns:
Type
void

setTo(to) → {void}

Source:
Set message receiver.
Parameters:
Name Type Description
to String 消息接收者
Returns:
Type
void

status() → {Number}

Source:
Get message status.
Returns:
返回消息状态
Type
Number

timestamp() → {Number}

Source:
Get message timestamp(server time).
Returns:
返回消息服务器时间
Type
Number

to() → {String}

Source:
Get message receiver.
Returns:
返回消息接收者
Type
String