new Message(content)
- Source:
- Implements:
Parameters:
Name | Type | Description |
---|---|---|
content |
Object | String | 消息内容 |
Members
(nullable) cid :String
- Source:
消息所在的 conversation id
Type:
- String
(nullable) deliveredAt :Date
- Source:
消息送达时间
Type:
- Date
from :String
- Source:
消息发送者
Type:
- String
id :String
- Source:
Type:
- String
needReceipt :Boolean
- Source:
- Deprecated:
- 指定是否需要送达回执请使用 Conversation#send 方法的 `options.receipt` 参数。
标记需要回执
Type:
- Boolean
(readonly) status :Symbol
- Source:
- Since:
- 3.2.0
消息状态,值为 module:leancloud-realtime.MessageStatus 之一
Type:
- Symbol
timestamp :Date
- Source:
消息发送时间
Type:
- Date
transient :Boolean
- Source:
- Deprecated:
- 指定是否作为暂态消息发送请使用 Conversation#send 方法的 `options.transient` 参数。 请不要将是否为暂态作为区分某些消息的标记,请使用富媒体消息的属性(attributes)或使用自定义消息类型。 该字段将在 v4.0 中移除。
标记暂态消息
Type:
- Boolean
updatedAt :Date
- Source:
- Since:
- 3.5.0
消息修改或撤回时间,可以通过比较其与消息的 timestamp 是否相等判断消息是否被修改过或撤回过。
Type:
- Date
Methods
(protected, static) parse(json, message) → {Message}
- Source:
- Implements:
解析处理消息内容
如果子类提供了 message,返回该 message 如果没有提供,将 json 作为 content 实例化一个 Message
Parameters:
Name | Type | Description |
---|---|---|
json |
Object | json 格式的消息内容 |
message |
Message | 子类提供的 message |
Returns:
- Type
- Message
(protected, static) validate() → {Boolean}
- Source:
- Implements:
判断给定的内容是否是有效的 Message,
该方法始终返回 true
Returns:
- Type
- Boolean
setNeedReceipt(needReceipt) → {Message}
- Source:
- Deprecated:
- 请使用 Conversation#send 方法的 `options.receipt` 选项代替。
设置是否需要送达回执
Parameters:
Name | Type | Description |
---|---|---|
needReceipt |
Boolean |
Returns:
self
- Type
- Message
setTransient(transient) → {Message}
- Source:
- Deprecated:
- 请使用 Conversation#send 方法的 `options.transient` 选项代替。
设置是否是暂态消息
Parameters:
Name | Type | Description |
---|---|---|
transient |
Boolean |
Returns:
self
- Type
- Message
(protected) toJSON() → {Object}
- Source:
- Implements:
将当前消息序列化为 JSON 对象
Returns:
- Type
- Object