Rate this page:

Conversation

Class that represents a conversation. A Conversation instance is returned by the Messenger.createConversation and Messenger.createConversationFromCache methods. Provides methods to send messages, manage participants, receive conversation events history etc.

Methods

addParticipants

Copy URL
- (

Promise<EditConversationEvent>

)addParticipants:(

ConversationParticipant[]

)participants

Add new participants to the conversation. Duplicated users are ignored. Triggers the MessengerEvents.EditConversation event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

editParticipants

Copy URL
- (

Promise<EditConversationEvent>

)editParticipants:(

ConversationParticipant[]

)participants

Change permissions for conversation participants. Duplicated users are ignored. This method does not add or remove participants. Use the Conversation.addParticipants and Conversation.removeParticipants methods instead. Triggers the MessengerEvents.EditConversation event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

markAsRead

Copy URL
- (

Promise<ReadEvent>

)markAsRead:(

number

)seq

Mark the event which has the specified sequence as read. This affects the current participant's ConversationParticipant.lastRead property and can be used to display unread messages. Triggers the MessengerEvents.Read event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • seq:

    number

Returns

removeParticipants

Copy URL
- (

Promise<EditConversationEvent>

)removeParticipants:(

ConversationParticipant[]

)participants

Remove participants from the conversation. Duplicated users are ignored. Will fail if any user does not exist. Triggers the MessengerEvents.EditConversation event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

retransmitEvents

Copy URL
- (

Promise<RetransmitEventsEvent>

)retransmitEvents:(

number

)eventsFrom

Request events in the specified sequence range to be sent from the cloud to this client. Only MessengerEvents.CreateConversation, MessengerEvents.EditConversation, MessengerEvents.SendMessage and MessengerEvents.EditMessage events can be retransmitted; any other events cannot. The method is used to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last conversation event sequence received from the cloud and last event sequence saved locally (if any). If the current user quits an uber conversation (see Conversation.uberConversation), messages that has been posted during the user's absence are not retransmitted later. The maximum number for requested events per method call is 100. Triggers multiple MessengerEvents.RetransmitEvents events (for each retransmitted event). To get the result, use one of these options:

Parameters

  • eventsFrom:

    number

    First event in sequence range, inclusive

  • eventsTo:

    number

    Last event in sequence range, inclusive

Returns

retransmitEventsFrom

Copy URL
- (

Promise<RetransmitEventsEvent>

)retransmitEventsFrom:(

number

)eventsFrom

Request a number of events starting with the specified sequence to be sent from the cloud to this client. Only MessengerEvents.CreateConversation, MessengerEvents.EditConversation, MessengerEvents.SendMessage and MessengerEvents.EditMessage events can be retransmitted; any other events cannot. The method is used to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last conversation event sequence received from the cloud and last event sequence saved locally (if any). If the current user quits an uber conversation (see Conversation.uberConversation), messages that has been posted during the user's absence are not retransmitted later. The maximum number for requested events per method call is 100. Triggers multiple MessengerEvents.RetransmitEvents events (for each retransmitted event). The result contains maximum available events for the current user even if it is less than the specified count value. To get the method call result use one of the following options:

Parameters

  • eventsFrom:

    number

    First event in sequence range, inclusive

  • count:

    number

    Number of events

Returns

retransmitEventsTo

Copy URL
- (

Promise<RetransmitEventsEvent>

)retransmitEventsTo:(

number

)eventsTo

Requests a number of events up to the specified sequence to be sent from the cloud to this client. Only MessengerEvents.CreateConversation, MessengerEvents.EditConversation, MessengerEvents.SendMessage and MessengerEvents.EditMessage events can be retransmitted; any other events cannot. The method is used to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last conversation event sequence received from the cloud and last event sequence saved locally (if any). If the current user quits an uber conversation (see Conversation.uberConversation), messages that has been posted during the user's absence are not retransmitted later. The maximum number for requested events per method call is 100. Triggers multiple MessengerEvents.RetransmitEvents events (for each retransmitted event). The result contains maximum available events for the current user even if it is less than the specified count value. To get the method call result use one of the following options:

Parameters

  • eventsTo:

    number

    Last event in sequence range, inclusive

  • count:

    number

    Number of events

Returns

sendMessage

Copy URL
- (

Promise<SendMessageEvent>

)sendMessage:(

string

)text

Send a message to the conversation. Triggers the MessengerEvents.SendMessage event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • text:

    string

  • payload:

    Object[]

    Optional

    Custom payload; can be an array of any objects, but not primitive types

Returns

setCustomData

Copy URL
- (

Promise<EditConversationEvent>

)setCustomData:(

any

)customData

Set new custom data for the conversation. Triggers the MessengerEvents.EditConversation event. To get the result, use one of these options:

Parameters

  • customData:

    any

Returns

setPublicJoin

Copy URL
- (

Promise<EditConversationEvent>

)setPublicJoin:(

boolean

)publicJoin

Set the public join flag and send changes to the server. Triggers the MessengerEvents.EditConversation event. To get the result, use one of these options:

Parameters

  • publicJoin:

    boolean

Returns

setTitle

Copy URL
- (

Promise<EditConversationEvent>

)setTitle:(

string

)title

Set a new title for the current conversation. Triggers the MessengerEvents.EditConversation event. To get the result, use one of these options:

Parameters

  • title:

    string

Returns

toCache

Copy URL
- (

SerializedConversation

)toCache

Serialize the conversation so it can be stored (e.g. in IndexedDB) and restored later via the Messenger.createConversationFromCache method.

typing

Copy URL
- (

Promise<TypingEvent,false>

)typing

Inform the cloud that the user is typing some text. The minimum interval between the two method calls should be 10 seconds. Triggers the MessengerEvents.Typing event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Returns

update

Copy URL
- (

Promise<EditConversationEvent>

)update

Send changes made via modifying conversation properties (Conversation.title, Conversation.publicJoin and Conversation.customData) to the cloud. Triggers the MessengerEvents.EditConversation event. To get the result, use one of these options:

Returns

Props

createdAt

Copy URL
@property () createdAt

UNIX timestamp (seconds) that specifies the time the conversation has been created.

customData

Copy URL
@property () customData

Any JavaScript structure with custom data, up to 5Kb. Note that setting this property does not send changes to the cloud. Use the Conversation.update method to send all changes at once or Conversation.setCustomData to update just the custom data.

direct

Copy URL
@property () direct

A direct conversation includes only 2 participants. There cannot be more than 1 direct conversation between the same 2 users. If one of these users tries to create a new direct conversation with the same participant via Messenger.createConversation, the method returns the existing direct conversation. A direct conversation cannot be uber and/or public.

lastSeq

Copy URL
@property () lastSeq

The sequence of the last event in the conversation.

lastUpdate

Copy URL
@property () lastUpdate

UNIX timestamp (seconds) that specifies the time of the last event in the conversation.

participants

Copy URL
@property () participants

The list of conversation participants alongside with their rights. The default permissions for all participants are: write / edit / remove their own messages (see ConversationParticipant.canWrite, ConversationParticipant.canEdit and ConversationParticipant.canRemove). The creator of the conversation is an owner by default. An owner of the conversation (see ConversationParticipant.isOwner):

  • can write messages
  • can edit and remove own and other participants' messages
  • can manage conversation participants

publicJoin

Copy URL
@property () publicJoin

If true, anyone can join the conversation by UUID. A public conversation cannot be direct. Note that setting this property does not send changes to the cloud. Use the Conversation.update method to send all changes at once or Conversation.setPublicJoin to update only the public join property.

title

Copy URL
@property () title

The conversation title. Note that setting this property does not send changes to the server. Use the Conversation.update method to send all the changes at once or Conversation.setTitle to update only the title.

uberConversation

Copy URL
@property () uberConversation

Users in a uber conversation are not able to retrieve messages that have been posted to the conversation after they quit or before they joined. A uber conversation cannot be direct.

uuid

Copy URL
@property () uuid

The universally unique identifier (UUID) of the conversation.