Options
All
  • Public
  • Public/Protected
  • All
Menu

A connection to an Elk M1 via a TCP socket.

Hierarchy

  • EventEmitter
    • ElkSocketConnection

Implements

Index

Constructors

constructor

Properties

Private _lastState

_lastState: ElkConnectionState = ElkConnectionState.Disconnected

The most recent state of the connection. Used by checkForStateChange to determine if a state change event needs to be emitted.

Private _socket

_socket: Socket | undefined

The underlying socket connection. Only defined when the connection is active (not Disconnected). Do not set this directly -- use setSocket

initialOptions

initialOptions: Partial<ElkSocketConnectionOptions>

options

The current options being used for this connection.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

state

Methods

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private checkForStateChange

  • checkForStateChange(): void

connect

  • Attempst to connect to the Elk M1 This should only be called when the connection is in a disconnected state, otherwise it will fail with a NotConnectableError

    throws

    {NotConnectableError} if the socket is not currently disconnected.

    Parameters

    • Default value timeout: number = this.options.connectTimeout

      How long to wait for a connection to be established, after which the connect() call will fail.

    Returns Promise<ElkSocketConnection>

disconnect

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private onSocketClose

  • onSocketClose(): void

Private onSocketConnect

  • onSocketConnect(): void

Private onSocketData

  • onSocketData(data: Buffer | string): void

Private onSocketEnd

  • onSocketEnd(): void

Private onSocketError

  • onSocketError(error: Error): void

Private onSocketTimeout

  • onSocketTimeout(): void

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Private setSocket

  • setSocket(socket?: Socket): void

write

  • write(data: string): Promise<unknown>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc