Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CascadeDriver

Encapsulate the set of available transport mechanisms and expose them in an implementation independent manner.

Hierarchy

  • any
    • CascadeDriver

Index

Constructors

constructor

  • Create a new CascadeDriver instance

    Parameters

    • subtransports: object

      the available subtransports

    • opts: OptionsImpl

      the connection options

    • transports: string[]

      a list of available transport names

    • cascadeNotifications: Emitter

      an emitter for emitting events on the Transports stream

    Returns CascadeDriver

Properties

Private cascadeNotifications

cascadeNotifications: Emitter

An emitter for emitting events on the Transports stream

Private emitter

emitter: Emitter

The emitter for emitting data, close, and error events

name

name: string | null

The name of the transport

Private onHandshakeError

onHandshakeError: function

The handshake error handler

Type declaration

    • (error: Error): void
    • Parameters

      • error: Error

      Returns void

Private onHandshakeSuccess

onHandshakeSuccess: function

The handshake handler

Type declaration

Private req

req: ConnectionRequest | null

The connection request.

Private responseReceived

responseReceived: boolean

A flag indicating whether a response has been received

Private transport

transport: Transport | null

The current transport object.

Private transportFactory

transportFactory: function

A factory function for creating transports

Type declaration

Private transports

transports: string[]

A list of available transport names

Methods

Private cascade

  • cascade(suppressClose?: undefined | false | true): boolean
  • Cascade to the next available transport

    A close event may be emitted on this stream and a cascade event is emitted on the Transports stream.

    Parameters

    • Optional suppressClose: undefined | false | true

      a flag indicating whether a close event should be suppressed

    Returns boolean

    true if attempting to connect, false if transports exhausted

close

  • Close the transport

    Returns StreamImpl

    this stream

Private closeQuietly

  • closeQuietly(): void
  • Close the current transport quietly, without generating any events.

    Returns void

connect

  • connect(request: ConnectionRequest, handshake: function, handshakeError: function): void

dispatch

  • dispatch(message: Buffer): void
  • Send a binary message to the server.

    Parameters

    • message: Buffer

      the message to send

    Returns void

Private internalConnect

  • internalConnect(): boolean
  • Connect to the current transport

    A cascading-connect event is emitted on the Transports stream.

    Returns boolean

    true if attempting to connect

Private onClose

  • Called when the transport emits a close event.

    Only emits a close event on this stream if it can't cascade further

    Parameters

    Returns void

Private onConnectionResponse

  • Called when the connection response is received.

    Parameters

    Returns ConnectionResponse | null

Private onData

  • onData(data: Buffer): void
  • Called when the transport emits a data event.

    Forwards the data and emits a data on this stream

    Parameters

    • data: Buffer

      the message data

    Returns void

Private onError

  • onError(error: Error): void
  • Called when the transport emits an error event.

    Forwards the data and emits a error on this stream

    Parameters

    • error: Error

      the error that occurred

    Returns void

Private onParsingError

  • onParsingError(error: Error): void
  • Called when the connection response cannot be parsed.

    Parameters

    • error: Error

      the error that occurred

    Returns void

Private selectTransport

  • selectTransport(suppressClose?: boolean): Transport | null
  • Select and create the next enabled transport.

    If there are no more transports then a close event may be emitted on this stream and a transports-exhausted event is emitted on the Transports stream.

    Parameters

    • Default value suppressClose: boolean = false

      a flag indicating whether a close event should be suppressed

    Returns Transport | null

    the selected transport