Class Conversation

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

Index

Accessors

createdAt

  • get (): string
  • Returns string

customData

  • get (): any
  • set (value: any): void
  • 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.

    Returns 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.

    Parameters

    • value: any

    Returns void

distinct

  • get (): boolean
  • set (value: boolean): void
  • 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.

    Returns 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.

    Parameters

    • value: boolean

    Returns void

lastRead

  • get (): any
  • Returns sequence of last event that was read by user. Used to display unread messages, events etc.

    Returns any

lastSeq

  • get (): any
  • Last event sequence for this conversation. Used with 'lastRead' to display unread messages and events.

    Returns any

lastUpdate

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

    Returns any

moderators

  • get (): Array<string>
  • Conversation moderator names list.

    Returns Array<string>

participants

publicJoin

  • get (): boolean
  • set (value: boolean): void
  • 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.

    Returns 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.

    Parameters

    • value: boolean

    Returns void

title

  • get (): string
  • set (value: string): void
  • 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.

    Returns 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.

    Parameters

    • value: string

    Returns void

uuid

  • get (): string
  • Universally unique identifier of current conversation. Used in methods like 'get', 'remove' etc.

    Returns string

Methods

addModerators

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

    Parameters

    • moderators: Array<string>

    Returns Promise<ConversationEvent>

addParticipants

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

    Parameters

    Returns Promise<ConversationEvent>

editParticipants

  • 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 EditConversation event for all messenger objects on all clients, including this one.

    Parameters

    Returns Promise<ConversationEvent>

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 Delivered event.

    Parameters

    • seq: number

    Returns 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 Read event for all messenger objects on all connected clients, including this one.

    Parameters

    • seq: number

    Returns void

remove

  • remove(): void
  • Remove current conversation. All participants, including this one, will receive the RemoveConversation event.

    Returns void

removeModerators

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

    Parameters

    • moderators: Array<string>

    Returns Promise<ConversationEvent>

removeParticipants

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

    Parameters

    Returns Promise<ConversationEvent>

retransmitEvents

  • retransmitEvents(eventsFrom: number, eventsTo: number): void
  • Request events in the specified sequence range to be sent from server into this client. 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 void

sendMessage

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

    • message: string
    • payload: Array<Payload>

    Returns Message

setCustomData

  • setCustomData(customData: any): void
  • Set the JS object custom data and send changes to the server.

    Parameters

    • customData: any

    Returns void

setDistinct

  • setDistinct(distinct: boolean): void
  • Set the distinct flag and send changes to the server.

    Parameters

    • distinct: boolean

    Returns void

setPublicJoin

  • setPublicJoin(publicJoin: boolean): void
  • Set the public join flag and send changes to the server.

    Parameters

    • publicJoin: boolean

    Returns void

setTitle

  • setTitle(title: string): void
  • Set the conversation title and send changes to the server.

    Parameters

    • title: string

    Returns void

toCache

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 boolean

    'true' is message was actually sent, 'false' if it was discarded.

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 void