Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Socket

Hierarchy

  • Disposable
    • Socket

Implements

  • DisposableObject

Index

Constructors

constructor

Accessors

isOpen

  • get isOpen(): boolean
  • Indicates whether the socket is open.

    Returns boolean

Methods

close

  • close(): void
  • Closes the current channel, connections and stops receiving events and requests. All pending outgoing requests get cancelled.

    Returns void

dispose

  • dispose(): void
  • Destroys the instance. After invoking the method, the instance cannot be used anymore.

    Returns void

isDisposed

  • isDisposed(): boolean
  • Indicates whether the instance is already disposed.

    Returns boolean

onError

  • Registers an error event listener.

    Parameters

    • handler: EventHandler<Error>

      Error handler.

    • Default value once: boolean = false

      Value indicating whether to handle any errors only once.

    Returns Subscription

onEvent

  • Registers an event listener.

    Parameters

    • name: string

      Event name.

    • handler: EventHandler

      Event handler.

    • Default value once: boolean = false

      Value indicating whether to handle the event only once.

    Returns Subscription

onRequest

open

  • open(channel: string): void
  • Opens connection and starts receiving events and requests.

    Parameters

    • channel: string

      Target channel to connect.

    Returns void

request

  • request<T>(path: string, payload?: any): Promise<T>
  • Sends a request.

    Type parameters

    • T

    Parameters

    • path: string

      Request path.

    • Optional payload: any

      Request payload.

    Returns Promise<T>

send

  • send(event: string, payload?: any): void
  • Sends an event.

    Parameters

    • event: string

      Event name.

    • Optional payload: any

      Event payload.

    Returns void

Static dereference

  • dereference(object: Object, keys?: Property[]): void
  • Dereferences object's keys. If a value of a key implements [[DisposableObject]] interface, [dispose] method of the value will be invoked.

    Parameters

    • object: Object

      Target object.

    • Optional keys: Property[]

      Keys to dereference. Optional. By default all keys will be dereferenced.

    Returns void

Static dispose

  • dispose(object: DisposableObject | Object, deref?: undefined | false | true): void
  • Tries to dispose a given object if it implements [[DisposableObject]] interface. If the object does not implement the interface, but [deref] param is passed, the method will try to dereference all object's keys.

    Parameters

    • object: DisposableObject | Object

      Target object to dispose.

    • Optional deref: undefined | false | true

      A value indicating whether to perform dereferncing.

    Returns void

Static isDisposable

  • isDisposable(object?: any): boolean
  • Indicates if a given object implements [[DisposableObject]] interface.

    Parameters

    • Optional object: any

      Target object.

    Returns boolean

Generated using TypeDoc