Class Messenger

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

Index

Methods

createConversation

  • createConversation(participants: Array<ConversationParticipant>, title?: string, distinct?: boolean, enablePublicJoin?: boolean, customData?: any, moderators?: Array<string>): void
  • Create a new conversation. Triggers the CreateConversation event on all connected clients that are mentioned in the 'participants' array.

    Dispatch:

    Parameters

    • participants: Array<ConversationParticipant>

      Array of participants alongside with access rights params

    • Optional title: string

      conversation title

    • Optional distinct: boolean

      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.

    • Optional enablePublicJoin: boolean

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

    • Optional 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.

    • Optional moderators: Array<string>

      Array of moderators

    Returns void

createConversationFromCache

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

    Parameters

    Returns Conversation

createMessageFromCache

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

    Parameters

    Returns Message

editUser

  • editUser(customData?: Object, privateCustomData?: Object): void
  • Edit current user information.

    Dispatch:

    Parameters

    • Optional customData: Object
    • Optional privateCustomData: Object

    Returns void

getConversation

  • getConversation(uuid: string): 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.

    Dispatch:

    Parameters

    • conversations: Array<string>

      Array of UUIDs

    Returns void

getMe

  • getMe(): string
  • Get the full Voximplant user identifier, ex 'username@appname.accname', for the current user

    Returns string

    current user short identifier

getUser

  • getUser(user_id: string): void
  • Get user information for the user specified by the full Voximplant user identifier, ex 'username@appname.accname'

    Dispatch:

    Parameters

    • user_id: string

      User identifier

    Returns void

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'

    Dispatch:

    Parameters

    • users: Array<string>

      List of user identifiers

    Returns void

joinConversation

  • joinConversation(uuid: string): void
  • Join current user to the conversation specified by the UUID

    Dispatch:

    Parameters

    • uuid: string

      Universally Unique Identifier of the conversation

    Returns void

leaveConversation

  • leaveConversation(uuid: string): void
  • Leave current user from the conversation specified by the UUID

    Dispatch:

    Parameters

    • uuid: string

      Universally Unique Identifier of the conversation

    Returns void

off

  • off(event: "CreateConversation" | "EditConversation" | "RemoveConversation" | "GetConversation" | "SendMessage" | "EditMessage" | "RemoveMessage" | "Typing" | "EditUser" | "GetUser" | "Error" | "RetransmitEvents" | "Read" | "Delivered" | "Subscribe" | "Unsubscribe" | "SetStatus", handler?: Function): void
  • Syntax shortcut for the 'removeEventListener'

    Parameters

    • event: "CreateConversation" | "EditConversation" | "RemoveConversation" | "GetConversation" | "SendMessage" | "EditMessage" | "RemoveMessage" | "Typing" | "EditUser" | "GetUser" | "Error" | "RetransmitEvents" | "Read" | "Delivered" | "Subscribe" | "Unsubscribe" | "SetStatus"
    • Optional handler: Function

    Returns void

on

  • on(event: "CreateConversation" | "EditConversation" | "RemoveConversation" | "GetConversation" | "SendMessage" | "EditMessage" | "RemoveMessage" | "Typing" | "EditUser" | "GetUser" | "Error" | "RetransmitEvents" | "Read" | "Delivered" | "Subscribe" | "Unsubscribe" | "SetStatus", handler: Function): void
  • Syntax shortcut for the 'addEventListener'

    Parameters

    • event: "CreateConversation" | "EditConversation" | "RemoveConversation" | "GetConversation" | "SendMessage" | "EditMessage" | "RemoveMessage" | "Typing" | "EditUser" | "GetUser" | "Error" | "RetransmitEvents" | "Read" | "Delivered" | "Subscribe" | "Unsubscribe" | "SetStatus"
    • handler: Function

    Returns void

removeConversation

  • removeConversation(uuid: string): void
  • Remove the conversation specified by the UUID

    Dispatch:

    Parameters

    • uuid: string

      Universally Unique Identifier of the conversation

    Returns void

setStatus

  • setStatus(status: boolean): void
  • Set user presence status. Triggers the 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.

    Dispatch:

    Parameters

    • status: boolean

      true if user is available for messaging.

    Returns void

subscribe

  • subscribe(users: Array<string>): void
  • Subscribe for user information change and presence status change. On change, the 'onSuscribe' event will be triggered.

    Dispatch:

    Parameters

    • users: Array<string>

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

    Returns void

unsubscribe

  • unsubscribe(users: Array<string>): void
  • Unsubscribe for user information change and presence status change.

    Dispatch:

    Parameters

    • users: Array<string>

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

    Returns void