Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Transports

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

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • Create a new Transports instance

    Parameters

    • subtransports: {}

      the available subtransports

    Returns Transports

Properties

Private Readonly emitter

emitter: Emitter

The emitter for emitting events on this stream

Private Readonly subtransports

subtransports: {}

The available subtransports

Type declaration

Methods

close

  • inheritdoc

    Will cause closeCallback to be called.

    Parameters

    • Optional reason: any

      the reason for closing the stream. This can be of any type. The type of the close reason should be documented in the class extending StreamImpl.

    Returns Stream

error

  • Close the stream. This will emit a 'close' event to any assigned listeners. No further events will be emitted.

    Parameters

    Returns Stream

get

  • Get a new CascadeDriver with a given set of options

    Parameters

    • options: OptionsImpl

      the options from which to create a driver.

    Returns CascadeDriver | null

    the cascade driver if the options contain valid transports, otherwise null

off

  • Remove a listener from a specified event.

    Example:

    // Bind a single listener to the 'foo' event and then deregister it
    var listener = function() {};
    stream.on('foo', listener);
    stream.off('foo', listener);
    

    Example:

    // Bind a listener to the 'foo' event and deregister all listeners
    var listener = function() {};
    stream.on('foo', listener);
    stream.off('foo');
    

    Parameters

    • events: string | CallbackMap
    • Optional listener: StreamCallback

      the listener to remove. All listeners for the event are removed if this is not specified. This argument is ignored if the first argument is a CallbackMap.

    Returns Stream

    this stream.

on

  • Register listeners against events.

    A single listener may be bound to an event by passing the event name and listener function.

    Multiple listeners may be bound by passing in a CallbackMap, mapping event names to listener functions.

    Example:

    // Bind a single listener to the 'foo' event
    stream.on('foo', function(arg1, arg2) {
        console.log("Called for 'foo' event", arg1, arg2);
    });
    

    Example:

    // Bind multiple listeners
    stream.on({
        foo : function() { ... },
        bar : function() { ... },
        baz : function() { ... }
    });
    

    It is possible to bind multiple listeners to the same event. In this case, the listeners will be called in the order they were bound.

    Parameters

    • events: string | CallbackMap

      the event name or CallbackMap mapping event names to listeners

    • Optional listener: StreamCallback

      the listener to bind to the event, if passed as string. This argument is ignored if the first argument is a CallbackMap.

    Returns Stream

    this stream.

Static create

  • create(subtransports?: undefined | {}): Transports
  • Create a new Transports object.

    Parameters

    • Optional subtransports: undefined | {}

      allows specifying the available subtransports for testing. If not specified, the Subtransports * will be used.

    Returns Transports

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.