Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Orbiter

The Orbiter class is the root class of every Orbiter client application. It provides basic tools for connecting to Union server, and gives the application access to the core Orbiter system modules, including:

Hierarchy

  • EventDispatcher
    • Orbiter

Index

Constructors

constructor

  • new Orbiter(configURL: string, traceLogMessages?: boolean): Orbiter
  • Parameters

    • configURL: string
    • Default value traceLogMessages: boolean = true

    Returns Orbiter

Properties

Readonly target

target: EventDispatcher

Optional Readonly window

window: Window

Methods

addEventListener

  • addEventListener(type: string, listener: Function, thisArg: any, priority?: number): boolean
  • Parameters

    • type: string
    • listener: Function
    • thisArg: any
    • Default value priority: number = 0

    Returns boolean

connect

  • connect(host?: undefined | string, ...ports: string[]): void
  • The connect() method attempts to connect to Union Server at the specified host and ports. If no host and ports are specified, Orbiter attempts to connect using the ConnectionManager's current list of hosts and ports.

    When a connection succeeds and the Orbiter object has been fully initialized, a OrbiterEvent.READY event is triggered. A OrbiterEvent.READY listener typically starts the application in motion, often by creating or joining rooms. Lower-level connection events can be handled via the application's ConnectionManager.

    Parameters

    • Optional host: undefined | string

      The string name or IP address of the domain on which Union Server is running. For more details, see the connect() method.

    • Rest ...ports: string[]

      A list of integer ports over which Orbiter should attempt to connect to Union Server. Orbiter will attempt to connect over the ports in the order specified. For example, if ports is set to 9100, 80, 443, then Orbiter will first attempt to connect to Union over port 9100; if the connection fails, Orbiter will automatically next attempt to connect over port 80, if that fails, Orbiter will attempt to connect to port 443. To add multiple hosts (not just multiple ports) to Orbiter's list of failover connections, use ConnectionManager.addConnection method. Wherever possible, to allow maximum connection success by Union clients, Union Server should be run on port 80.

    Returns void

disableConsole

  • disableConsole(): void
  • Returns void

disableHTTPFailover

  • disableHTTPFailover(): void
  • Instructs Orbiter to use persistent socket connections only when attempting to connect to specified hosts and ports. When HTTP failover is disabled, Orbiter does not automatically attempt to establish backup HTTP connections if all persistent socket connection attempts fail.

    Returns void

disableStatistics

  • disableStatistics(): void
  • Disables statistics tracking for this Orbiter object.

    Returns void

disconnect

  • disconnect(): void
  • Terminates any open connection to the server. If the disconnection attempt succeeds, ConnectionManager dispatches the ConnectionManagerEvent.CLIENT_KILL_CONNECT and ConnectionManagerEvent.DISCONNECT events, and the Orbiter object dispatches a OrbiterEvent.CLOSE event.

    The Orbiter class's disconnect() method is a convenience wrapper for the ConnectionManager.disconnect method.

    Returns void

dispatchEvent

  • dispatchEvent(event: Event): void
  • Parameters

    • event: Event

    Returns void

dispose

  • dispose(): void
  • Permanently disables this object and releases all of its resources. Once dispose() is called, the object can never be used again. Use dispose() only when purging an object from memory, as is required when unloading an iframe. To simply disconnect an Orbiter object, use disconnect().

    Returns void

enableConsole

  • enableConsole(): void
  • Returns void

enableHTTPFailover

  • enableHTTPFailover(): void
  • Instructs Orbiter to automatically try connecting via HTTP when it is unable to establish a persistent socket connection over all specified hosts and ports. HTTP failover is enabled by default. HTTP connections are less responsive than persistent socket connections, but have a higher chance of connecting from behind a firewall. For the most granular control over connection sequence, type, hosts, and ports, use the ConnectionManager class directly.

    Returns void

enableStatistics

  • enableStatistics(): void
  • Enables statistics tracking for this Orbiter object. To retrieve statistics, use the getStatistics() method.

    Returns void

getAccountManager

  • Returns a reference to the application's AccountManager instance, which is automatically created by Orbiter; the AccountManager class provides a set of services relating to registering and logging-in user accounts. For complete details see the main class entry for the AccountManager class.

    Returns AccountManager

getClientID

  • getClientID(): string
  • Returns string

getClientManager

  • Returns a reference to the application's ClientManager instance, which is automatically created by Orbiter; the ClientManager class creates and provides access to Client instances. Client instances store information about clients on the server, including client attributes, IP address, ping time, and connection time. For complete details see the main class entry for the ClientManager class.

    Returns ClientManager

getConnectionManager

  • Returns a reference to the application's ConnectionManager instance, which is automatically created by Orbiter; the ConnectionManager class is used to establish a connection to the server. For complete details see the main class entry for the ConnectionManager class.

    Returns ConnectionManager

getConnectionMonitor

  • Returns a reference to the application's ConnectionMonitor instance, which manages heartbeat (ping) and automatic disconnection and reconnection services.

    Returns ConnectionMonitor

getListeners

  • getListeners(type: string): EventListener[]
  • Parameters

    • type: string

    Returns EventListener[]

getLog

  • Returns a reference to the application debugging log, which describes operations occurring on the client, and can show low-level client/server communications.

    Returns Logger

getMessageManager

  • Returns a reference to the application's MessageManager instance, which is automatically created by Orbiter; the MessageManager class provides a set of services relating to sending messages to and receiving messages from the server. For complete details see the main class entry for the MessageManager class.

    Returns MessageManager

getRoomManager

  • Returns a reference to the application's RoomManager, which is created automatically by Orbiter; the RoomManager class is used to create, destroy, observe, join, and access rooms.

    Returns RoomManager

getServer

  • Returns a reference to the application's Server instance, which is automatically created by Orbiter; the Server class provides access to global server data and functions. For complete details see the main class entry for the Server class.

    Returns Server

getSessionID

  • getSessionID(): string
  • The Union session ID for this Orbiter instance, if available.

    Returns string

getSnapshotManager

  • getSnapshotManager(): SnapshotManager
  • Returns SnapshotManager

getStatistics

  • Returns a reference to a Statistics object for this connection, which provides metrics such as KB/second transfer rate and number of messages sent and received.

    Due to the performance cost associated with statistics tracking, the returned Statistics object returned by getStatistics() is disabled by default, and provides no data. To enable statistics tracking, invoke the Orbiter class's enableStatistics() method.

    Returns Statistics | null

getSystem

  • Returns a reference to the application's System class, whose static variables provide Orbiter version information.

    Returns System

hasListener

  • hasListener(type: string, listener: Function, thisArg: any): boolean
  • Parameters

    • type: string
    • listener: Function
    • thisArg: any

    Returns boolean

isHTTPFailoverEnabled

  • isHTTPFailoverEnabled(): boolean
  • Indicates whether Orbiter will automatically try connecting via HTTP when it is unable to establish a persistent socket connection over all specified hosts and ports.

    Returns boolean

isReady

  • isReady(): boolean
  • Returns a Boolean indicating whether Orbiter currently has an active, fully initialized connection to the server.

    Returns boolean

    true if the client is in a ready state; false otherwise.

loadConfig

  • loadConfig(configURL: string): void
  • Loads the client-configuration file. When the file load completes, Orbiter automatically attempts to connect to Union Server using the settings specified by the configuration file.

    The configuration file has the following format:

        <?xml version="1.0"?>
        <config>
            <connections>
                <connection host="hostNameOrIP1" port="portNumber1" type="connectionType1" senddelay="milliseconds1" secure="false" />
                <connection host="hostNameOrIPn" port="portNumbern" type="connectionTypen" senddelay="millisecondsn" secure="false" />
            </connections>
            <autoreconnectfrequency>frequency</autoreconnectfrequency>
            <connectiontimeout>duration</connectiontimeout>
            <heartbeatfrequency>frequency</heartbeatfrequency>
            <readytimeout>timeout</readytimeout>
            <loglevel>level</loglevel>
        </config>

    When the secure attribute is true, communication is conducted over WSS or HTTPS using the environment's TLS implementation.

    Parameters

    • configURL: string

    Returns void

removeEventListener

  • removeEventListener(type: string, listener: Function, thisArg: any): boolean
  • Parameters

    • type: string
    • listener: Function
    • thisArg: any

    Returns boolean

secureConnect

  • secureConnect(host: string, ...ports: string[]): void
  • The secureConnect() method is identical to the connect() method, except that it uses an encrypted connection (TLS or SSL) rather than an unencrypted connection. Before secureConnect() can be used, Union Server must be configured to accept client communications over a secure gateway, which includes the installation of a server-side security certificate.

    Parameters

    • host: string
    • Rest ...ports: string[]

    Returns void

selectConnectionListener

  • selectConnectionListener(e: Event): void
  • Parameters

    • e: Event

    Returns void

self

  • Returns a reference to the application's own Client object (i.e., the "current client").

    Returns CustomClient | Client | null

setServer

  • setServer(host?: undefined | string, ...ports: string[]): void
  • Specifies the host and port for future connection attempts. The setServer() method does not attempt to open a new connection; to connect after specifying the server, use Orbiter's connect() method.

    Parameters

    • Optional host: undefined | string

      The string name or IP address of the domain on which Union Server is running. For more details, see the connect() method.

    • Rest ...ports: string[]

      A list of integer ports over which Orbiter should attempt to connect to Union Server.

    Returns void

updateSnapshot

  • updateSnapshot(snapshot: Snapshot): void
  • Updates the specified snapshot object with the latest information available on the server. For details on snapshots, see the Snapshot class.

    Parameters

    • snapshot: Snapshot

      The snapshot object to be updated. Must be an instance of any Snapshot subclass.

    Returns void