@akiroz/thalamus
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Thalamus

test

An opinionated application messaging framework based on MQTT.

Differences from plain MQTT

+ RPC support
+ Server redundancy / load-balancing
- Guaranteed delivery (MQTT QoS 1 / 2)

Messages requiring acknowledgement must use RPC and applications are expected to implement their own retry mechanisms.

API

class Thalamus

  • constructor(serverOptList: MQTT.IClientOptions[])

  • thalamus.servers List of MQTT client objects

  • async publish(topic: string, payload: Uint8Array)

  • async subscribe(topic: string, handler: SubHandler)

  • async unsubscribe(topic: string, handler?: SubHandler)

  • async call(topic: string, params: Param = {}, opt = defaultOptions): Promise<Result>

  • async register(topic: string, handler: (param, topic) => Result)

  • thalamus.on("connect", (i) => {}) server i connected (i = 0-based index)

  • thalamus.on("close", (i) => {}) server i disconnected (i = 0-based index)

  • thalamus.on("error", (err, i) => {}) server i error (i = 0-based index)

Readme

Keywords

none

Package Sidebar

Install

npm i @akiroz/thalamus

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

45.4 kB

Total Files

18

Last publish

Collaborators

  • akiroz