SIGN UP

Messenger

Messenger class used to control messaging functions. Can't be instantiated directly (singleton), please use getMessenger to get the class instance.

Methods

createConversation

createConversation(participants: Array<ConversationParticipant>, title: string, distinct: boolean, enablePublicJoin: boolean, customData: any, moderators: Array<string>): void

Create a new conversation. Triggers the Messengerevents.ErrorCreateConversation event on all connected clients that are mentioned in the 'participants' array.

Parameters

  • participants:

    Array<ConversationParticipant>

    Array of participants alongside with access rights params

  • title:

    string
    Optional

    conversation title

  • distinct:

    boolean
    Optional

    If two conversations are created with same set of users and moderators and both have 'distinct' flag, second creation of conversation (with the same participants) will fail with the UUID of conversation already created. Note that changing users or moderators list will clear 'distinct' flag.

  • moderators:

    Array<string>
    Optional

    Array of moderators

  • enablePublicJoin:

    boolean
    Optional

    If set to 'true', anyone can join conversation by uuid

  • customData:

    any
    Optional

    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

  • Return:

    void

createConversationFromCache

createConversationFromCache(cacheConversation: SerializedConversation): Conversation

Restore conversation from cache that is previously created by the 'toCache' method.

Parameters

Returns

createMessageFromCache

createMessageFromCache(cacheMessage: SerializedMessage): Message

Restore message from cache that is previously created by the 'toCache' method.

Parameters

Returns

editUser

editUser(customData: Object, privateCustomData: Object): void

Edit current user information.

Parameters

  • customData:

    Object
    Optional
  • privateCustomData:

    Object
    Optional

Returns

  • Return:

    void

getConversation

getConversation(uuid: string): void

Get conversation by it's UUID

Parameters

  • uuid:

    string

Returns

  • Return:

    void

getConversations

getConversations(conversations: Array<string>): void

Get multiple conversations by array of UUIDs. Maximum 30 conversation. Note that calling this method will result in multiple 'getConversation' events.

Parameters

  • conversations:

    Array<string>

    Array of UUIDs

Returns

  • Return:

    void

getMe

getMe(): string

Get the full Voximplant user identifier, ex 'username@appname.accname', for the current user

Returns

  • Return:

    string

getUser

getUser(user_id: string): Promise<UserEvent>

Get user information for the user specified by the full Voximplant user identifier, ex 'username@appname.accname'

Parameters

  • user_id:

    string

    User identifier

Returns

getUsers

getUsers(users: Array<string>): void

Get user information for the users specified by the array of the full Voximplant user identifiers, ex 'username@appname.accname'

Parameters

  • users:

    Array<string>

    List of user identifiers

Returns

  • Return:

    void

joinConversation

joinConversation(uuid: string): void

Join current user to the conversation specified by the UUID

Parameters

  • uuid:

    string

    Universally Unique Identifier of the conversation

Returns

  • Return:

    void

leaveConversation

leaveConversation(uuid: string): void

Leave current user from the conversation specified by the UUID

Parameters

  • uuid:

    string

    Universally Unique Identifier of the conversation

Returns

  • Return:

    void

off

off(event: MessengerEvents, handler: Function): void

Syntax shortcut for the 'removeEventListener'

Parameters

Returns

  • Return:

    void

on

on(event: MessengerEvents, handler: Function): void

Syntax shortcut for the 'addEventListener'

Parameters

Returns

  • Return:

    void

removeConversation

removeConversation(uuid: string): void

Remove the conversation specified by the UUID

Parameters

  • uuid:

    string

    Universally Unique Identifier of the conversation

Returns

  • Return:

    void

setStatus

setStatus(status: boolean): void

Set user presence status. Triggers the MessengerEvents.SetStatus event for all messenger objects on all connected clients which are subscribed for notifications about this user. Including this one if conditions are met.

Parameters

  • status:

    boolean

    true if user is available for messaging.

Returns

  • Return:

    void

subscribe

subscribe(users: Array<string>): void

Subscribe for user information change and presence status change. On change, the 'onSuscribe' event will be triggered.

Parameters

  • users:

    Array<string>

    List of full Voximplant user identifiers, ex 'username@appname.accname'

Returns

  • Return:

    void

unsubscribe

unsubscribe(users: Array<string>): void

Unsubscribe for user information change and presence status change.

Parameters

  • users:

    Array<string>

    List of full Voximplant user identifiers, ex 'username@appname.accname'

Returns

  • Return:

    void