A transport providing the ability of sending and receiving WebSocket messages to and from Juju controllers and models.

Param

The WebSocket instance already connected to a Juju controller or model.

Param

A callback to be called after the transport closes the connection. The callback receives the close code.

Param

When enabled, all API messages are logged at debug level.

Hierarchy

  • Transport

Constructors

  • Parameters

    • ws: WebSocket
    • closeCallback: CloseCallback
    • debug: boolean

    Returns Transport

Properties

_callbacks: Record<number, Callback<unknown>>
_closeCallback: CloseCallback
_counter: number
_debug: boolean
_ws: WebSocket

Methods

  • Handle responses arriving from Juju.

    Parameters

    • data: string

    Returns void

  • Close the transport, and therefore the connection.

    Parameters

    • Optional callback: ((code: number, callback: CloseCallback) => void)

      Called after the transport is closed, the callback receives the close code and optionally another callback. It is responsibility of the callback to call the provided callback if present.

        • (code: number, callback: CloseCallback): void
        • Parameters

          • code: number
          • callback: CloseCallback

          Returns void

    Returns void

  • Send a message to Juju.

    Type Parameters

    • R

    Parameters

    • req: JujuRequest

      A Juju API request, typically in the form of an object like {type: 'Client', request: 'DoSomething', version: 1, params: {}}. The request must not be already serialized and must not include the request id, as those are responsibilities of the transport.

    • resolve: ((value: R) => void)

      Function called when the request is successful.

        • (value: R): void
        • Parameters

          • value: R

          Returns void

    • reject: ((error: Error) => void)

      Function called when the request is not successful.

        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    Returns void

Generated using TypeDoc