Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Server

Provides access to global server data and functions, and a means of communicating with server modules. To access the Server object, use getServer()

Hierarchy

  • EventDispatcher
    • Server

Index

Constructors

constructor

  • Parameters

    Returns Server

Properties

Readonly target

target: EventDispatcher

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

clearModuleCache

  • clearModuleCache(): void
  • Asks the server to remove all current module class definitions from memory. Subsequently instantiated modules will use the newly loaded module class definitions, allowing module developers to update Union Server's modules at runtime without restarting the server. Note that currently running modules are not reloaded. For example, if a room module is already active for a room, clearModuleCache() will not affect that module. If the active module's class file has changed and clearModuleCache() is invoked, then the new class definition will not be used until the next time the room is removed and recreated.

    The clearModuleCache() method does not affect script modules. Union Server always uses the latest version of all script modules on disk, so there is no script module cache to clear.

    Returns void

dispatchEvent

  • dispatchEvent(event: Event): void
  • Parameters

    • event: Event

    Returns void

getListeners

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

    • type: string

    Returns EventListener[]

getServerTime

  • getServerTime(): number
  • Returns the approximate current time on the server in UTC, using "milliseconds from January 1 1970" format. The time is approximated by adding the following two values:

    • The last time sent by the server (either the connection time or the last response to syncTime()).
    • The number of milliseconds elapsed on the client side since the server's time was last received

    To retrieve the most accurate possible approximation, first call syncTime(), then call getServerTime() from within the ServerEvent.TIME_SYNC callback.

    Returns number

getUPCVersion

  • Returns the version of the UPC protocol in use by Union Server.

    Returns VersionNumber

getVersion

  • getVersion(): string
  • Returns the version of the Union Server to which Orbiter is currently connected.

    Returns string

hasListener

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

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

    Returns boolean

isWatchingForProcessedUPCs

  • isWatchingForProcessedUPCs(): boolean
  • Indicates whether the current client is currently watching for processed UPCs.

    Returns boolean

removeEventListener

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

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

    Returns boolean

resetUPCStats

  • resetUPCStats(): void
  • Asks Union Server to reset server-side UPC-processing statistics. If the request is granted, Union Server clears its list of the longest UPC-message-processing times. The statistics-reset is reflected in any subsequent UPCStatsSnapshot retrieval. By default, resetUPCStats() requires administrator privileges.

    Returns void

sendMessage

  • sendMessage(messageName: string, includeSelf?: boolean, filters?: Filter, ...rest: string[]): void
  • Sends a message to the entire server. To receive the message, recipient clients must register a message listener via MessageManager's addMessageListener() method.

    Parameters

    • messageName: string

      The name of the message to invoke.

    • Default value includeSelf: boolean = false

      Indicates whether to send the message to the current client (i.e., the client that invoked sendMessage()). Defaults to false (don't echo to the sender).

    • Optional filters: Filter

      Specifies one or more filters for the message. A filter specifies a requirement that each client must meet in order to receive the message. For example, a filter might indicate that only those clients with the attribute "team" set to "red" should receive the message. For complete details, see the Filter class. If filters is null, all clients on the server receive the message.

    • Rest ...rest: string[]

    Returns void

sendModuleMessage

  • sendModuleMessage(moduleID: string, messageName: string, messageArguments: {}): void
  • Sends the specified message to the specified server module.

    Parameters

    • moduleID: string

      The ID of the module to which the message will be sent. Modules are assigned IDs in the server's union.xml configuration file.

    • messageName: string

      The name of the message to send.

    • messageArguments: {}

      The message arguments, specified as dynamic instance variables on a generic object.

      • [key: string]: string

    Returns void

setIsWatchingForProcessedUPCs

  • setIsWatchingForProcessedUPCs(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

stopWatchingForProcessedUPCs

  • stopWatchingForProcessedUPCs(): void
  • Asks the server to stop sending UPC-processing notifications. By default, stopWatchingForProcessedUPCs() requires administrator privileges.

    Returns void

syncTime

  • syncTime(): void
  • Asks the server to send the current time. When the time is received, ServerEvent.TIME_SYNC fires. Use getServerTime() to retrieve the current approximate time on the server (i.e., the last sync time plus elapsed time on the client). If syncTime() has never been called, getServerTime() returns the client connection time plus time elapsed on the client.

    Returns void

watchForProcessedUPCs

  • watchForProcessedUPCs(): void
  • Asks the server to notify the current client upon processing any UPC message. Notifications trigger the ServerEvent.UPC_PROCESSED event. Details about each message processed are provided in a UPCProcessingRecord accessible via the ServerEvent's getUPCProcessingRecord() method. By default, watchForProcessedUPCs() requires administrator privileges.

    Returns void