Real-time publisher and subscriber clients for Harper using MQTT, WebSocket, and Server-Sent Events (SSE).
- Node.js v14+
- mqtt package (v5.14.1) - for MQTT clients
- ws package (v8.18.0) - for WebSocket clients
- eventsource package (v3.0.2) - for SSE clients
npm installnode mqtt-publish.jsnode mqtt-subscribe.jsnode ws-publish.jsnode ws-subscribe.jsnode sse-subscribe.jsNote: SSE is unidirectional (server to client only), so there is no SSE publisher.
All clients follow the same tier progression:
- Tier 0 (MVP): Single publish, automatic database persistence for WebSocket/SSE
- Tier 1: Database persistence enabled (MQTT:
retain: true) - Tier 2: Continuous publishing every 5 seconds
- MQTT: Full pub/sub broker, topic-based routing, QoS levels
- WebSocket: Bidirectional, direct resource connection, lower overhead
- SSE: Unidirectional (server→client), simple HTTP-based, automatic reconnection