This page has small, task-focused snippets for the data modality. Each snippet
assumes a constructed client:
Publish a reading (lossy, default)
The default lane is the QUIC datagram lane. It has the lowest latency. Use it
for high-rate telemetry where the freshest value wins.
Publish an event that must arrive (reliable lane)
Set reliable: true for application events, commands, or settlements. This
lane is ordered and retried per publisher.
Subscribe with a + (single-segment) wildcard
+ matches exactly one path segment. Here, it matches any room.
Subscribe to a whole subtree with #
# matches the rest of the path and must be the trailing segment. One
subscription covers everything under events/.
Publish retained current state
The relay caches a retained message and delivers it to every future subscriber
on attach. Use it for “current state.”
Clear a retained topic
Publish a zero-length payload with retained: true. Do this typically on
clean shutdown. Dashboards then show “offline” without a heartbeat timeout.
Tell a bootstrap value from a live one
Retained values that the relay re-emits on attach arrive with
msg.retained === true. Render the snapshot. Then track live updates.
Fan in from a whole fleet to one dashboard
Every message carries fromClientId. One subscription thus demuxes many
publishers without a track per device.
Publish and consume JSON
Payloads are opaque bytes. Encode and decode JSON yourself.
Route by topic with a dispatch table
Use one subscription on a subtree and many handlers keyed by sub-filter. This
is the classic event-bus shape.
Stop a single subscription
Watch connection state
Pass onState to react to reconnects. The SDK replays subscriptions and
retained values automatically after a drop.
Publish from Python
The Python surface mirrors the TS one with snake_case keywords.
Stay wire-compatible without the client
Use the exported codec to build or parse frames yourself.
Keep the top-level topic segment concrete and meaningful (sensors, events,
devices). It selects the underlying track. It is thus also your coarse
fan-out and routing boundary.