Options
Menu

Class ConvergenceDomain

This represents a single connection to a specific Domain in Convergence. All interactions with the Domain start with this class, through several "services" that provide the following functionality:

This object itself is the result of a successful connection and authentication to a Convergence server via one of the Convergence connection methods. Or, to begin working in an offline state, instantiate this class directly.

See the Events section for all the possible events that could be emitted from a domain.

Hierarchy

Index

Constructors

constructor

  • Constructs a new ConvergenceDomain using the default options.

    Parameters

    • url: string

      The url of the convergence domain to connect to.

    • options: IConvergenceOptions

      Options that configure how the convergence domain is configured.

    Returns ConvergenceDomain

Methods

activities

  • Gets the ActivityService, which is used for interacting with Activities.

    const activityService = domain.activities();
    

    Returns ActivityService

    The ActivityService from this ConvergenceDomain.

addListener

chat

  • Gets the ChatService, which is used to send and receive chat messages.

    example
    
    const chatService = domain.chat();
    

    Returns ChatService

    The ChatService for this ConvergenceDomain.

connectAnonymously

  • connectAnonymously(displayName?: string | (() => Promise<string>)): Promise<void>
  • Connects to a Convergence Domain using anonymous authentication.

    Parameters

    • displayName: string | (() => Promise<string>)

      The optional display name to use for the anonymous user. The display name can be supplied directly or can be supplied as a factory function that will return a promise to obtain it.

    Returns Promise<void>

    A Promise which will be resolved upon successful connection and authentication.

connectWithJwt

  • connectWithJwt(jwt: string | (() => Promise<string>)): Promise<void>
  • Connects to a Convergence Domain using a JSON Web Token (JWT) for authentication.

    Parameters

    • jwt: string | (() => Promise<string>)

      A valid JSON Web Token (JWT) indicating the Domain User to connect as. The JWT can be supplied directly or can be supplied as a factory function that will return a promise to obtain it.

    Returns Promise<void>

    A Promise which will be resolved upon successful connection and authentication.

connectWithPassword

  • Connects to a Convergence Domain using username / password authentication.

    Parameters

    • credentials: IUsernameAndPassword | (() => Promise<IUsernameAndPassword>)

      The username and password of the Convergence Domain User to connect as. The credentials can be supplied directly or can be supplied as a factory function that will return a promise to obtain them.

    Returns Promise<void>

    A Promise which will be resolved upon successful connection and authentication.

disconnect

  • disconnect(): void
  • Disconnects from the server, if connected.

    Returns void

dispose

  • dispose(): void
  • Disconnects from the server and releases all resources this domain is using. After calling dispose(), the domain will no longer be usable.

    example
    
    domain.dispose()
      .then(() => console.log("disposed!"))
      .catch(e => console.error(e));
    

    Returns void

    A promise that is resolved when the ConvergenceDomain is disposed.

events

  • Provides the events emitted by this object as an Observable stream.

    example
    
    eventEmitter.events()
      .filter(e => e.name === "myevent")
      .subscribe(e => console.log(e));
    

    Returns Observable<IConvergenceDomainEvent>

    An Observable stream of all events emitted by this object.

id

  • id(): string
  • Returns string

    The unique ID of this domain.

identity

  • Gets the IdentityService, which is used for obtaining information about Users.

    const identityService = domain.identity();
    

    Returns IdentityService

    The IdentityService for this ConvergenceDomain.

initializeOffline

  • initializeOffline(username: string | (() => Promise<string>)): Promise<void>
  • Initializes the domain without connecting to the server. The method must be provided the username of the normal domain user that will eventually connect as.

    experimental

    Parameters

    • username: string | (() => Promise<string>)

      The username of the domain user to connect offline as.

    Returns Promise<void>

    A Promise that will be completed when the domain is ready to use.

isConnected

  • isConnected(): boolean
  • Determines if the domain is connected.

    Returns boolean

    true if the domain is connected; false otherwise.

isDisconnected

  • isDisconnected(): boolean
  • Determines if the domain is disconnected.

    Returns boolean

    true if the domain is disconnected; false otherwise.

isDisposed

  • isDisposed(): boolean
  • Determines if this domain is disposed.

    Returns boolean

    True if the domain is disposed; false otherwise.

models

  • Gets the ModelService, which is used for interacting with Real Time Models.

    const modelService = domain.models();
    

    Returns ModelService

    The ModelService for this ConvergenceDomain.

namespace

  • namespace(): string
  • Returns string

    The namespace of this domain.

off

on

once

options

presence

  • Gets the PresenceService, which is used to gain insight into the presence of Domain Users.

    example
    
    const presenceService = domain.presence();
    

    Returns PresenceService

    The PresenceService for this ConvergenceDomain.

reconnect

  • reconnect(token?: string | (() => Promise<string>)): Promise<void>
  • Reconnects to the specified domain using a previously generated reconnect token.

    Parameters

    • token: string | (() => Promise<string>)

      The reconnect token to use for authentication.

    Returns Promise<void>

    A Promise which will be resolved upon successful connection and authentication.

removeAllListeners

removeListener

removeListeners

session

url

  • url(): string
  • Returns string

    The url of the domain.

Object literals

Events

Events: object

A list of all the events that could be emitted from a domain.

AUTHENTICATED

AUTHENTICATED: string = AuthenticatedEvent.NAME

Emitted when the domain successfully (re)authenticated. The actual emitted event is an AuthenticatedEvent.

AUTHENTICATING

AUTHENTICATING: string = AuthenticatingEvent.NAME

Emitted when the domain is actively attempting to authenticate. The actual emitted event is an AuthenticatingEvent.

AUTHENTICATION_FAILED

AUTHENTICATION_FAILED: string = AuthenticationFailedEvent.NAME

Emitted when the domain attempted to (re)authenticate but failed. The actual emitted event is an AuthenticationFailedEvent.

CONNECTED

CONNECTED: string = ConnectedEvent.NAME

Emitted when the domain successfully (re)connected to the server. The actual emitted event is a ConnectedEvent.

CONNECTING

CONNECTING: string = ConnectingEvent.NAME

Emitted when the domain is actively attempting to connect to the server. The actual emitted event is a ConnectingEvent.

CONNECTION_FAILED

CONNECTION_FAILED: string = ConnectionFailedEvent.NAME

Emitted when a connection attempt failed. The actual emitted event is a ConnectionFailedEvent.

CONNECTION_SCHEDULED

CONNECTION_SCHEDULED: string = ConnectionScheduledEvent.NAME

Emitted when the domain is scheduled to attempt to reconnect. The actual emitted event is a ConnectionScheduledEvent.

DISCONNECTED

DISCONNECTED: string = DisconnectedEvent.NAME

Emitted when the domain is currently disconnected and is not attempting to automatically reconnect. The actual emitted event is a DisconnectedEvent.

ERROR

ERROR: string = ErrorEvent.NAME

Emitted when the domain encountered an unexpected error. The actual emitted event is an ErrorEvent.

INTERRUPTED

INTERRUPTED: string = InterruptedEvent.NAME

Emitted when the domain's connection was interrupted. This indicates that the domain is in a state where it is currently disconnected, but is automatically and continuously attempting to reconnect.

The actual emitted event is an InterruptedEvent.