Data
client, bind a clientId, then publish and subscribe against hierarchical
topics. One Data instance reuses a single MoQT session across every publish
and subscribe.
Import
github.com/clutchcall/clutchcall-sdk/go, clutchcall, com.clutchcall:clutchcall-sdk, ClutchCall.SDK);
the method names and wire format are identical.
Data
The client. Construct one per process or device.
Constructor options
Bearer token for the relay session. Carries the tenant and the
clientId
claims. The same token authorizes every other modality.This client’s stable id. Attached as
fromClientId on every published
message so subscribers can attribute the source.Relay hostname. Defaults to the platform relay.
Optional connection-state callback. Fires as the underlying QUIC/MoQT session
moves through
Connecting → Connected → Reconnecting → Closed / Failed. The
session auto-reconnects and replays subscriptions.Inject a custom WebTransport factory — a Node polyfill or a test double.
Optional; the browser SDK uses the native implementation.
Methods
publish(args)
Publish one message. The SDK adds the (fromClientId, topic) header and selects
the MoQT track from the topic’s top-level segment.
Full hierarchical topic, e.g.
sensors/room1/temperature. UTF-8, ≤ 255 bytes.Opaque payload bytes. Encode JSON / text / protobuf yourself.
false → lossy QUIC datagram lane (lowest latency). true → ordered, retried
subgroup-stream lane (guaranteed in-order per publisher).true → the relay caches the latest payload on this topic and delivers it to
every late-joining subscriber on attach. Publish a zero-length payload
with retained: true to clear it.Promise<void> (TS) / None (Python). Resolves once the frame is
handed to the transport.
subscribe(args, onMessage)
Subscribe with an MQTT-style filter. The callback fires for every matching
message. The SDK opens one MoQT subscription on the filter’s top-level segment
and filters the rest of the path client-side.
MQTT-style filter.
+ matches one segment, # matches the rest (trailing
only). The top-level segment must be concrete.Invoked for every message whose topic matches the filter. Malformed frames are
dropped silently before the callback.
DataSubscription (TS: Promise<DataSubscription>). Call
.close() to stop receiving.
close()
Tear down every publication and subscription and close the MoQT session.
Idempotent.
Handles and types
DataMessage
What onMessage receives.
The full topic string the publisher sent (not the filter).
The
clientId of the publisher — for attribution / per-client demux.The opaque message bytes.
true when this is a retained/bootstrap value the relay re-emitted on attach;
false for live traffic. Lets you treat a snapshot differently from updates.DataSubscription
The handle returned by subscribe. Carries topicFilter and exposes:
Connection state and events
The data client does not raise per-message events beyond youronMessage
callback. Lifecycle is surfaced through the optional onState constructor
callback, which mirrors the underlying session:
| State | Meaning |
|---|---|
Connecting | First QUIC/MoQT handshake in flight. |
Connected | Session up; publishes and subscribes flow. |
Reconnecting | Transport dropped; the SDK is re-establishing and will replay subscriptions. |
Closed | You called close(). |
Failed | Unrecoverable — token rejected, relay unreachable. |
On reconnect the SDK replays your subscriptions automatically, and the relay
re-emits matching retained values, so a transient drop re-bootstraps current
state without app code.
Wire helpers (advanced)
For interop tests or callers that want to stay wire-compatible while bypassing the high-level client, the subpath also exports the raw codec and matcher:from_client_id and topic are bounded at 255 bytes; topLevelSegment
throws on a leading wildcard. These mirror the frame layout in
Details.
Dropping to the substrate
The data modality is a thin convention over MoQT frames. If you need a shape it does not cover, import@clutchcall/sdk/moqt and use MoqtClient.publishFrame /
subscribeFrame directly under your own namespace — the same auto-reconnect,
capability routing, and relay fan-out apply. See
Realtime Tracks.
