Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Manager

The Manager class handles all the Namespaces and Sockets that we're using

Hierarchy

Index

Properties

autoConnect

autoConnect: boolean

If we should auto connect (also used when creating Sockets). Set via the opts object

connecting

connecting: Socket[]

The currently connected sockets

nsps

nsps: object

All the namespaces currently controlled by this Manager, and the Sockets that we're using to communicate with them

Type declaration

opts

The connect options that we used when creating this Manager

readyState

readyState: string

The state of the Manager. Either 'closed', 'opening', or 'open'

uri

uri: string

The URI that this manager is for (host + port), e.g. 'http://localhost:4000'

Methods

addEventListener

  • addEventListener(event: string, fn: Function): Emitter

connect

  • see

    open( fn );

    Parameters

    • Optional fn: function
        • (err?: any): void
        • Parameters

          • Optional err: any

          Returns void

    Returns Manager

emit

  • emit(event: string, ...args: any[]): Emitter
  • Emits 'event' with the given args

    Parameters

    • event: string

      The event that we want to emit

    • Rest ...args: any[]

      Optional arguments to emit with the event

    Returns Emitter

    Emitter

hasListeners

  • hasListeners(event: string): boolean
  • Returns if we have listeners for a particular event

    Parameters

    • event: string

      The event that we want to check if we've listeners for

    Returns boolean

    True if we have listeners for this event, false otherwise

listeners

  • listeners(event: string): Function[]
  • Returns all the callbacks for a particular event

    Parameters

    • event: string

      The event that we're looking for the callbacks of

    Returns Function[]

    An array of callback Functions, or an empty array if we don't have any

off

  • off(event: string, fn?: Function): Emitter
  • Removes a listener for a particular type of event. This will either remove a specific listener, or all listeners for this type of event

    Parameters

    • event: string

      The event that we want to remove the listener of

    • Optional fn: Function

      The function to remove, or null if we want to remove all functions

    Returns Emitter

    This Emitter

on

  • on(event: string, fn: Function): Emitter
  • Adds a listener for a particular event. Calling multiple times will add multiple listeners

    Parameters

    • event: string

      The event that we're listening for

    • fn: Function

      The function to call when we get the event. Parameters depend on the event in question

    Returns Emitter

    This Emitter

once

  • once(event: string, fn: Function): Emitter
  • Adds a listener for a particular event that will be invoked a single time before being automatically removed

    Parameters

    • event: string

      The event that we're listening for

    • fn: Function

      The function to call when we get the event. Parameters depend on the event in question

    Returns Emitter

    This Emitter

open

  • Sets the current transport socket and opens our connection

    Parameters

    • Optional fn: function

      An optional callback to call when our socket has either opened, or failed. It can take one optional parameter of type Error

        • (err?: any): void
        • Parameters

          • Optional err: any

          Returns void

    Returns Manager

    This Manager

randomizationFactor

  • randomizationFactor(): number
  • randomizationFactor(v: number): Manager
  • Gets the randomisation factor used in the exponential backoff jitter when reconnecting

    default

    0.5

    Returns number

  • Sets the randomisation factor used in the exponential backoff jitter when reconnecting

    default

    0.5

    Parameters

    • v: number

    Returns Manager

    This Manager

reconnection

  • reconnection(): boolean
  • reconnection(v: boolean): Manager
  • Gets if we should reconnect automatically

    default

    true

    Returns boolean

  • Sets if we should reconnect automatically

    default

    true

    Parameters

    • v: boolean

      True if we should reconnect automatically, false otherwise

    Returns Manager

    This Manager

reconnectionAttempts

  • reconnectionAttempts(): number
  • reconnectionAttempts(v: number): Manager
  • Gets the number of reconnection attempts we should try before giving up

    default

    Infinity

    Returns number

  • Sets the number of reconnection attempts we should try before giving up

    default

    Infinity

    Parameters

    • v: number

      The number of attempts we should do before giving up

    Returns Manager

    This Manager

reconnectionDelay

  • reconnectionDelay(): number
  • reconnectionDelay(v: number): Manager
  • Gets the delay in milliseconds between each reconnection attempt

    default

    1000

    Returns number

  • Sets the delay in milliseconds between each reconnection attempt

    default

    1000

    Parameters

    • v: number

      The delay in milliseconds

    Returns Manager

    This Manager

reconnectionDelayMax

  • reconnectionDelayMax(): number
  • reconnectionDelayMax(v: number): Manager
  • Gets the max reconnection delay in milliseconds between each reconnection attempt

    default

    5000

    Returns number

  • Sets the max reconnection delay in milliseconds between each reconnection attempt

    Parameters

    • v: number

      The max reconnection dleay in milliseconds

    Returns Manager

    This Manager

removeAllListeners

removeEventListener

  • removeEventListener(event: string, fn?: Function): Emitter

removeListener

  • removeListener(event: string, fn?: Function): Emitter

socket

  • Creates a new Socket for the given namespace

    Parameters

    • nsp: string

      The namespace that this Socket is for

    Returns Socket

    A new Socket, or if one has already been created for this namespace, an existing one

timeout

  • timeout(): number
  • timeout(v: number): Manager
  • Gets the timeout in milliseconds for our connection attempts

    default

    20000

    Returns number

  • Sets the timeout in milliseconds for our connection attempts

    Parameters

    • v: number

    Returns Manager

    This Manager

Generated using TypeDoc