pamoja for TypeScript - v0.2.0
    Preparing search index...

    Interface TransportHandlers

    The operations a link written in JavaScript supplies to stand as a transport.

    Implement this for a link pamoja does not ship, a vendor SDK, a proprietary radio, or a cloud client, and hand it to Transport.fromHandlers. The result composes like any transport: as a ladder rung, under a fault injector, or driven directly. Each method may return a promise or a plain value, and is called on the object, so a class instance works as it is. A method that throws or rejects fails the call that reached it, with the message it threw.

    interface TransportHandlers {
        connect(): void | Promise<void>;
        recv?(): | DeliveredMessage
        | Promise<DeliveredMessage | null | undefined>
        | null
        | undefined;
        send(topic: string, payload: Buffer): void | Promise<void>;
        subscribe(topic: string): void | Promise<void>;
    }
    Index
    • Establishes the link. Called again on every reconnect.

      Returns void | Promise<void>

    • Waits for the next message on a subscribed topic, or resolves to null once the link has ended. Present, it is called again as soon as it settles, from the moment the transport connects, and what it delivers is queued for the receiving side. One that throws ends the link until the next connect, and the next receive rejects with what it threw. Absent, the link only sends and a ladder never listens on it.

      Returns
          | DeliveredMessage
          | Promise<DeliveredMessage | null | undefined>
          | null
          | undefined

    • Publishes a payload to a topic.

      Parameters

      • topic: string
      • payload: Buffer

      Returns void | Promise<void>

    • Subscribes to a topic filter, in the syntax the link understands. A ladder places its filters again each time the link reconnects.

      Parameters

      • topic: string

      Returns void | Promise<void>