Class StpWebSocketsConnector

Implements a connector to STP's native OAA pub/sub service via WebSockets

Implements

IStpConnector - IStpConnector

Hierarchy

  • StpWebSocketsConnector

Implements

Constructors

Properties

DEFAULT_TIMEOUT: number = 30
connstring: string
machineId: undefined | string
name: undefined | string

Unique service instance name, different if there are concurrent instances running

onError: undefined | ((error) => void)

Event handler invoked when a connection error occurs

Param

Error description

onInform: undefined | ((message) => void)

Event handler invoked by STP when a message matching one of the Solvables is posted by some service

Param

STP API message to handle

onRequest: undefined | ((message) => string[])

Event handler invoked by STP when a service makes a request matching one of the Solvables

Param

STP API message to handle

Returns

STP API response

serviceName: undefined | string
sessionId: undefined | string
socket: null | WebSocket
solvables: undefined | string[]
timeout: undefined | number

Accessors

Methods

  • Connect and register the service, informing of the subscriptions it handles / consumes

    Parameters

    • serviceName: string

      Name of the service that is connecting

    • solvables: string[]

      Array of messages that this service handles

    • timeout: number = ...

      Optional number of seconds to wait for a connection before failing

    • machineId: null | string = null

      Optional machine Id to use. If not provided, it is set to some unique Id.

    • sessionId: null | string = null

      Optional session Id to use. If not provided:

      1. the suffix to the WebSocket connection string is used
      2. if no WebSocket suffix was provided, the machineId is used
      3. If machineId is not provided, a unique random Id is used.

    Returns Promise<undefined | string>

    The actual sessionId used - the one provided here or a default set by STP

  • Send a message/command to STP

    Parameters

    • message: string

      STP API message to send

    • timeout: number = ...

    Returns Promise<void>

  • Make a STP request - equivalent to an RPC call

    Parameters

    • message: string

      STP API message to send

    • timeout: number = ...

    Returns Promise<any>

    STP API responses

Generated using TypeDoc