Conversation

AV. Conversation

new Conversation(name, optionsopt)

Source:

An AV.Conversation is a local representation of a LeanCloud realtime's conversation. This class is a subclass of AV.Object, and retains the same functionality of an AV.Object, but also extends it with various conversation specific methods, like get members, creators of this conversation.

Parameters:
Name Type Attributes Description
name String The name of the Role to create.
options Object <optional>
Properties
Name Type Attributes Description
isSystem Boolean <optional>
Set this conversation as system conversation.
isTransient Boolean <optional>
Set this conversation as transient conversation.

Methods

addMember(member)

Source:
Add a member to this conversation
Parameters:
Name Type Description
member String

broadcast(fromClient, message, optionsopt, authOptionsopt) → {Promise}

Source:
Send realtime broadcast message to all clients, via this conversation, using HTTP request.
Parameters:
Name Type Attributes Description
fromClient String Sender's client id.
message String | Object The message which will send to conversation. It could be a raw string, or an object with a `toJSON` method, like a realtime SDK's Message object. See more: https://leancloud.cn/docs/realtime_guide-js.html#消息.
options Object <optional>
Properties
Name Type Attributes Description
pushData Object <optional>
Push data to this message. See more: 推送消息内容.
validTill Object <optional>
The message will valid till this time.
authOptions AuthOptions <optional>
Returns:
Type
Promise

getCreator() → {String}

Source:
Get current conversation's creator.
Returns:
Type
String

getLastMessageAt() → {Date}

Source:
Get the last message's time.
Returns:
Type
Date

getMembers() → {Array.<String>}

Source:
Get this conversation's members
Returns:
Type
Array.<String>

getMutedMembers() → {Array.<String>}

Source:
Get this conversation's members who set this conversation as muted.
Returns:
Type
Array.<String>

getName()

Source:
Get this conversation's name field.
Returns:
String

isSystem() → {Boolean}

Source:
Returns true if this conversation is system conversation.
Returns:
Type
Boolean

isTransient() → {Boolean}

Source:
Returns true if this conversation is transient conversation.
Returns:
Type
Boolean

send(fromClient, message, optionsopt, authOptionsopt) → {Promise}

Source:
Send realtime message to this conversation, using HTTP request.
Parameters:
Name Type Attributes Description
fromClient String Sender's client id.
message String | Object The message which will send to conversation. It could be a raw string, or an object with a `toJSON` method, like a realtime SDK's Message object. See more: https://leancloud.cn/docs/realtime_guide-js.html#消息
options Object <optional>
Properties
Name Type Attributes Description
transient Boolean <optional>
Whether send this message as transient message or not.
toClients Array.<String> <optional>
Ids of clients to send to. This option can be used only in system conversation.
pushData Object <optional>
Push data to this message. See more: 推送消息内容
authOptions AuthOptions <optional>
Returns:
Type
Promise