Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Swampyer

Hierarchy

  • Swampyer

Index

Constructors

constructor

Properties

Readonly closeEvent

closeEvent: { addEventListener: (callback: (...args: CloseEventData) => void) => () => void; waitForNext: () => Promise<CloseEventData> } = ...

Type declaration

  • addEventListener: (callback: (...args: CloseEventData) => void) => () => void
      • (callback: (...args: CloseEventData) => void): () => void
      • Parameters

        • callback: (...args: CloseEventData) => void
            • (...args: CloseEventData): void
            • Parameters

              • Rest ...args: CloseEventData

              Returns void

        Returns () => void

          • (): void
          • Returns void

  • waitForNext: () => Promise<CloseEventData>
      • (): Promise<CloseEventData>
      • Returns Promise<CloseEventData>

Readonly openEvent

openEvent: { addEventListener: (callback: (...args: [WelcomeDetails]) => void) => () => void; waitForNext: () => Promise<[WelcomeDetails]> } = ...

Type declaration

Accessors

isOpen

  • get isOpen(): boolean
  • Returns boolean

isReconnecting

  • get isReconnecting(): boolean
  • Returns boolean

Methods

call

  • call(uri: string, args?: unknown[], kwargs?: Object, options?: CommonOptions): Promise<unknown>
  • Call a WAMP URI and get its result

    Parameters

    • uri: string

      The WAMP URI to call

      If the uriBase options was defined when opening the connection then uriBase will be prepended to the provided URI (unless the appropriate value is set in options)

    • args: unknown[] = []

      Positional arguments

    • kwargs: Object = {}

      Keyword arguments

    • options: CommonOptions = {}

      Settings for how the registration should be done. This may vary between WAMP servers

    Returns Promise<unknown>

    Arbitrary data returned by the call operation

close

  • close(reason?: string, message?: string): Promise<void>
  • Close the WAMP connection

    Parameters

    • reason: string = 'wamp.close.system_shutdown'

      The reason for the closure

    • Optional message: string

      Some descriptive message about why the connection is being closed

    Returns Promise<void>

open

  • Open a WAMP connection.

    The library will not try to automatically reconnect if the operation fails or if the connection gets closed.

    Parameters

    • transportProvider: TransportProvider

      The transport provider to open the WAMP connection through

    • options: OpenOptions

      The options for configuing the WAMP connection

    Returns Promise<WelcomeDetails>

    Details about the successful WAMP session

openAutoReconnect

  • Open a WAMP connection that will automatically reconnect in case of failure or closure.

    Parameters

    • getTransportProvider: (attempt: number, ...closeData: [reason: CloseReason, details: CloseDetails]) => TransportProvider

      A function that should return a fresh TransportProvider for each reconnection attempt.

      The attempt argument for this callback will be 0 for the initial connection attempt. For all reconnection attempts, the attempt value will start from 1.

    • options: AutoReconnectionOpenOptions

      The options for configuring the WAMP connection

    Returns void

publish

  • publish(uri: string, args?: unknown[], kwargs?: Object, options?: PublishOptions): Promise<void>
  • Publish an event on the given WAMP URI

    Parameters

    • uri: string

      The WAMP URI to publish the event for

      If the uriBase options was defined when opening the connection then uriBase will be prepended to the provided URI (unless the appropriate value is set in options)

    • args: unknown[] = []

      Positional arguments

    • kwargs: Object = {}

      Keyword arguments

    • options: PublishOptions = {}

      Settings for how the registration should be done. This may vary between WAMP servers

    Returns Promise<void>

register

  • Register a callback for a WAMP URI

    NOTE: The library will try to forward as much data as possible from the error thrown by the {@link handler} function to the caller via the kwargs. Make sure that the errors do not contain any sensitive information.

    Type parameters

    • R = any

    • A: any[] = any

    • K = any

    Parameters

    • uri: string

      The URI to register for.

      If the uriBase options was defined when opening the connection then uriBase will be prepended to the provided URI (unless the appropriate value is set in options)

    • handler: RegistrationHandler<R, A, K>

      The callback function that will handle invocations for this uri

    • options: CommonOptions = {}

      Settings for how the registration should be done. This may vary across WAMP servers

    Returns Promise<number>

    The registration ID (useful for unregistering)

subscribe

  • Subscribe to publish events on a given WAMP URI.

    If a subscription already exists for a given subscription ID then all subscription handlers will get called when an event occurs on the subscription ID.

    Type parameters

    • A: any[] = any

    • K = any

    Parameters

    • uri: string

      The URI to subscribe to

      If the uriBase options was defined when opening the connection then uriBase will be prepended to the provided URI (unless the appropriate value is set in options)

    • handler: SubscriptionHandler<A, K>

      The callback function that will handle subscription events for this uri

    • options: CommonOptions = {}

      Settings for how the subscription should be done. This may vary across WAMP servers

    Returns Promise<SubscriptionIdentifier>

    The subscription ID (useful for unsubscribing)

unregister

  • unregister(registrationId: number): Promise<void>
  • Unregister an existing registration

    Parameters

    • registrationId: number

      The registration ID returned by register()

    Returns Promise<void>

unsubscribe

  • unsubscribe(subscriptionData: SubscriptionIdentifier, unsubscribeAll?: boolean): Promise<void>
  • Unsubscribe existing subscriptions given a subscription ID and handler function.

    Parameters

    • subscriptionData: SubscriptionIdentifier

      The subscription data returned by subscribe()

    • Optional unsubscribeAll: boolean

      Multiple subscriptions can have the same ID if the same client subscribes to the same URI. Set this to true if you would like to unsubscribe all existing subscriptions for this client for the given subscription ID.

    Returns Promise<void>

Generated using TypeDoc