Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Connection

Connection is the abstract superclass of HTTPConnection and WebSocketConnection; it is used internally, and is not intended for direct use by developers. For information on communication with Union Server, see connect() method, the WebSocketConnection class and the HTTPDirectConnection and HTTPIFrameConnection classes.

The Connection class dispatches the following events:

  • ConnectionEvent.BEGIN_CONNECT
  • ConnectionEvent.BEGIN_HANDSHAKE
  • ConnectionEvent.READY
  • ConnectionEvent.CONNECT_FAILURE
  • ConnectionEvent.CLIENT_KILL_CONNECT
  • ConnectionEvent.SERVER_KILL_CONNECT
  • ConnectionEvent.DISCONNECT
  • ConnectionEvent.RECEIVE_UPC
  • ConnectionEvent.SEND_DATA
  • ConnectionEvent.RECEIVE_DATA
  • ConnectionEvent.SESSION_TERMINATED
  • ConnectionEvent.SESSION_NOT_FOUND

Hierarchy

Implements

Index

Constructors

constructor

  • new Connection(host?: undefined | string, port?: undefined | number, type?: undefined | string): Connection
  • Parameters

    • Optional host: undefined | string
    • Optional port: undefined | number
    • Optional type: undefined | string

    Returns Connection

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

applyAffinity

  • applyAffinity(data?: any): void
  • Parameters

    • Optional data: any

    Returns void

connect

  • connect(): void
  • Attempts to connect to Union Server at the current host and port. The result of the attempt is reported via ConnectionEvent.READY and ConnectionEvent.CONNECT_FAILURE events.

    The connect() method is not normally intended for direct use.

    Returns void

disconnect

  • disconnect(): void
  • Closes the connection to Union Server.

    The disconnect() method is not normally intended for direct use.

    Returns void

dispatchEvent

  • dispatchEvent(event: Event): void
  • Parameters

    • event: Event

    Returns void

dispose

  • dispose(): void
  • Permanently disables the connection object.

    Returns void

getHost

  • getHost(): string | null
  • Returns the host on which the connection will be opened or has been opened.

    Returns string | null

    The host name or ip, as a string.

getListeners

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

    • type: string

    Returns EventListener[]

getPort

  • getPort(): number | null
  • Returns the port on which the connection will be opened or has been opened.

    Returns number | null

    A number from 1 to 65535.

getRequestedHost

  • getRequestedHost(): string | null
  • Returns the host that was requested for this connection via setServer(). If that host is a load balancing DNS server, the actual host used for the connection (as returned by getHost()) might differ from the requested host.

    Returns string | null

    The requested host name or ip, as a string.

getType

  • getType(): string | null
  • Returns the type of the connection, as one of the types specified by the ConnectionType class.

    Returns string | null

    A string representing the connection type.

hasListener

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

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

    Returns boolean

isReady

  • isReady(): boolean
  • Indicates whether this connection is currently in a "ready" state.

    Returns boolean

isValid

  • isValid(): boolean
  • Indicates whether this connection is considered valid. Valid connections are those that are currently in a "ready" state, or are currently disconnected but successfully achieved a "ready" state in the most recent connection attempt.

    Returns boolean

removeEventListener

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

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

    Returns boolean

send

  • send(data: any): void
  • Sends the specified data to Union Server. The send() method is not intended for direct use.

    Parameters

    • data: any

    Returns void

setOrbiter

  • setOrbiter(orbiter: Orbiter): void
  • Assigns the Orbiter object for which this IConnection will provide server communication services. This method is invoked automatically by the ConnectionManager when the Connection object is added to the ConnectionManager's connection list.

    Parameters

    Returns void

setServer

  • setServer(host?: undefined | string, port?: undefined | number): void
  • Assigns the host and port to use with the connect() method.

    Parameters

    • Optional host: undefined | string

      The server address (typically an IP address or domain name).

    • Optional port: undefined | number

      A port number between 1 and 65536. Note that ports from 1-7 are normally reserved for use by the operating system!

    Returns void

toString

  • toString(): string