SIGN UP

Conversation

Conversation instance. Created by Messenger.createConversation(). Used to send messages, add or remove users, change moderators list etc.

Methods

addModerators

addModerators(moderators: Array<string>): Promise<ConversationEvent>

Add new moderators to the conversation. Duplicated users are ignored. Will fail if any user does not exist. Triggers the MessengerEvents.EditConversation event for all messenger objects on all clients, including this one.

Parameters

  • moderators:

    Array<string>

Returns

addParticipants

addParticipants(participants: Array<ConversationParticipant>): Promise<ConversationEvent>

Add new participants to the conversation. Duplicated users are ignored. Will fail if any user does not exist. Triggers the MessengerEvents.EditConversation event for all messenger objects on all clients, including this one.

Parameters

Returns

editParticipants

editParticipants(participants: Array<ConversationParticipant>): Promise<ConversationEvent>

Change access rights for the existing participants. This function doesn't apply any changes to the participant list. Use addParticipant or <a href="#removeparticipant>removeParticipant instead. Triggers the MessengerEvents.EditConversation event for all messenger objects on all clients, including this one.

Parameters

Returns

markAsDelivered

markAsDelivered(seq: number): void

Mark event as handled by current logged-in device. If single user is logged in on multiple devices, this can be used to display delivery status by subscribing to the MessengerEvents.Delivered event.

Parameters

  • seq:

    number

Returns

  • Return:

    void

markAsRead

markAsRead(seq: number): void

Mark the event with the specified sequence as 'read'. This affects 'lastRead' and is used to display unread messages and events. Triggers the MessengerEvents.Read event for all messenger objects on all connected clients, including this one.

Parameters

  • seq:

    number

Returns

  • Return:

    void

remove

remove(): void

Remove current conversation. All participants, including this one, will receive the MessengerEvents.RemoveConversation event.

Returns

  • Return:

    void

removeModerators

removeModerators(moderators: Array<string>): Promise<ConversationEvent>

Remove moderators from the conversation. Duplicated users are ignored. Will fail if any user does not exist. Triggers the MessengerEvents.EditConversation event for all messenger objects on all clients, including this one.

Parameters

  • moderators:

    Array<string>

Returns

removeParticipants

removeParticipants(participants: Array<ConversationParticipant>): Promise<ConversationEvent>

Remove participants from the conversation. Duplicated users are ignored. Will fail if any user does not exist. Triggers the MessengerEvents.EditConversation event for all messenger objects on all clients, including this one.

Parameters

Returns

retransmitEvents

retransmitEvents(eventsFrom: number, eventsTo: number): Promise<RetransmitEvent>

Request events in the specified sequence range to be sent from server into this client. Maximum 100 events can be requested by one method call. Sequence numbers of the resulting events may contain 'holes' due to the server-side implementation. Method is used to get history or get missed events in case of network disconnect. Please note that server will not push any events that was missed due to the client being offline. Client should use this method to request all events based on the last event sequence received from the server and last event sequence saved locally (if any).

Parameters

  • eventsFrom:

    number

    first event in range sequence, inclusive

  • eventsTo:

    number

    last event in range sequence, inclusive

Returns

sendMessage

sendMessage(message: string, payload: Array<Payload>): Message

Parameters

  • message:

    string
  • payload:

    Array<Payload>
    Optional

Returns

setCustomData

setCustomData(customData: any): void

Set the JS object custom data and send changes to the server.

Parameters

  • customData:

    any

Returns

  • Return:

    void

setDistinct

setDistinct(distinct: boolean): void

Set the distinct flag and send changes to the server.

Parameters

  • distinct:

    boolean

Returns

  • Return:

    void

setPublicJoin

setPublicJoin(publicJoin: boolean): void

Set the public join flag and send changes to the server.

Parameters

  • publicJoin:

    boolean

Returns

  • Return:

    void

setTitle

setTitle(title: string): void

Set the conversation title and send changes to the server.

Parameters

  • title:

    string

Returns

  • Return:

    void

toCache

toCache(): SerializedConversation

Serialize conversation so it can be stored into some storage (like IndexedDB) and later restored via Messenger.createConversationFromCache

Returns

typing

typing(): boolean

Calling this method will inform backend that user is typing some text. Calls within 10s interval from the last call are discarded.

Returns

  • Return:

    boolean

update

update(): void

Send conversation changes to the server: title, public join flag, distinct flag and custom data. Used to send all changes modified via properties. Changes via 'setTitle', 'setPublicJoin' etc are sent instantly.

Returns

  • Return:

    void

Properties

createdAt

createdAt: string

customData

customData: any

JavaScript object with custom data, up to 5kb. Note that setting this property does not send changes to the server. Use the 'update' to send all changes at once or 'setCustomData' to update and set the custom data.

distinct

distinct: boolean

If two conversations are created with same set of users and moderators and both have 'distinct' flag, second create call will fail with the UUID of conversation already created. Note that changing users or moderators list will clear 'distinct' flag. Note that setting this property does not send changes to the server. Use the 'update' to send all changes at once or 'setDistinct' to update and set the distinct flag.

lastRead

lastRead: any

Returns sequence of last event that was read by user. Used to display unread messages, events etc.

lastSeq

lastSeq: any

Last event sequence for this conversation. Used with 'lastRead' to display unread messages and events.

lastUpdate

lastUpdate: any

UNIX timestamp integer that specifies the time of the last event in the conversation. It's same as 'Date.now()' divided by 1000.

moderators

moderators: Array<string>

Conversation moderator names list.

participants

participants: Array<ConversationParticipant>

Conversation participants list alongside with their rights.

publicJoin

publicJoin: boolean

If set to 'true', anyone can join conversation by UUID. Note that setting this property does not send changes to the server. Use the 'update' to send all changes at once or 'setPublicJoin' to update and set the public join flag.

title

title: string

Sets current conversation title. Note that setting this property does not send changes to the server. Use the 'update' to send all changes at once or 'setTitle' to update and set the title.

uuid

uuid: string

Universally unique identifier of current conversation. Used in methods like 'get', 'remove' etc.