SIGN UP

Messenger

Messenger class is 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 either the MessengerEvents.Error or MessengerEvents.CreateConversation 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

    The feature allows users from any Voximplant account to join the conversation using its 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 Conversation.update to send all changes at once or Conversation.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.The method triggers the MessengerEvents.GetConversation or MessengerEvents.Error event. The handler function receives the EventHandlers.ConversationEvent object with UUID etc.

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

Remove a handler for the specified event. The method is a shorter equivalent for removeEventListener. If a number of events has the same function as a handler, the method can be called multiple times with the same handler argument.

Parameters

Returns

  • Return:

    void

on

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

Register a handler for the specified event. The method is a shorter equivalent for addEventListener. One event can have more than one handler; handlers are executed in order of registration. Use the Messenger.off method to delete a handler.

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; a method call triggers the MessengerEvents.Subscribe event.

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; a method call triggers the MessengerEvents.Unsubscribe event.

Parameters

  • users:

    Array<string>

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

Returns

  • Return:

    void