RelaySubscriber
Defined in: relay-sdks/ts/src/connect.ts:123
A connection that can only subscribe. Create one with connectRelaySubscriber. Publishing
uses a separate connection and token; see connectRelayPublisher.
Properties
Section titled “Properties”closed
Section titled “closed”readonly closed: Promise<{ error?: unknown;}>;Defined in: relay-sdks/ts/src/connect.ts:159
Resolves once for local shutdown, peer closure, or failure. It never rejects.
expiresAt
Section titled “expiresAt”readonly expiresAt: Date | undefined;Defined in: relay-sdks/ts/src/connect.ts:168
When the relay will end this connection for its credential’s expiry: the RelayCredential’s expiresAt, or the
JWT’s exp claim, read without verifying it. undefined when neither is known. The relay closes the session then
with UNAUTHORIZED in phase connection; open a replacement before it. Supervised connections do.
maxAgeSupported
Section titled “maxAgeSupported”readonly maxAgeSupported: boolean;Defined in: relay-sdks/ts/src/connect.ts:175
Whether the relay’s SETUP declared subscriber max age (the MoQ Timestamp extension’s MAX_AGE option, 0x915C4), so
a parameters.maxAge on subscribe, subscribeSwitchable, subscribeEvents, update() or trackSource.subscribe
reaches it. While false the SDK leaves maxAge off every request, as the extension requires. moq-dev main declares
it; moq-relay 0.17.x does not. Fixed for the connection’s life.
trackSource
Section titled “trackSource”readonly trackSource: MoqTrackSource;Defined in: relay-sdks/ts/src/connect.ts:157
This connection seen through the generic MoqTrackSource contract, for integrations such as
players: subscribe, fetch, and trackStatus in protocol terms, plus closed. It lists no
tracks and cannot close the connection; the application that opened the connection owns
shutdown.
Methods
Section titled “Methods”close()
Section titled “close()”close(): void;Defined in: relay-sdks/ts/src/connect.ts:177
Close this connection and all requests on it. Idempotent.
Returns
Section titled “Returns”void
namespaceEvents()
Section titled “namespaceEvents()”namespaceEvents(options): NamespaceEvents;Defined in: relay-sdks/ts/src/connect.ts:150
Discover which namespaces under a prefix are announced, as bounded async events with the same
ownership rules as subscribeEvents: the iterator owns one SUBSCRIBE_NAMESPACE request, and
break/return, close() or the signal cancels it. It first yields announced for each namespace
already announced, then one event per announce and withdrawal. The relay sends no marker between
the two. A relay rejection ends it with SubscriptionRequestError, the connection ending with
SubscriptionConnectionClosedError, a full queue with SubscriptionOverflowError; a relay that
finishes the request ends it cleanly. See spec/behavior.md, “Discovery”, for the timing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
NamespaceEventOptions |
Returns
Section titled “Returns”subscribe()
Section titled “subscribe()”subscribe(options, handlers?): RelaySubscription;Defined in: relay-sdks/ts/src/connect.ts:130
Ask the relay for a track’s objects, in any payload format, without discovering or loading a
catalog. Returns at once with a cancellable handle whose subscribed settles when the relay
answers and whose ended settles once the subscription can no longer deliver;
handlers.onSubscribed and handlers.onError report the same answer as callbacks.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
RelayTrackOptions |
handlers? |
RelaySubscriptionHandlers |
Returns
Section titled “Returns”subscribeEvents()
Section titled “subscribeEvents()”subscribeEvents(options, buffer?): SubscriptionEvents;Defined in: relay-sdks/ts/src/connect.ts:140
Bounded async events. Owns its subscription; break/return cancels it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
RelayTrackOptions |
buffer? |
SubscriptionEventOptions |
Returns
Section titled “Returns”subscribeSwitchable()
Section titled “subscribeSwitchable()”subscribeSwitchable(options, handlers?): SwitchableSubscription;Defined in: relay-sdks/ts/src/connect.ts:138
Subscribe to a track through a handle that can move to another track in the same namespace
make-before-break: switchTo opens the new subscription while this one keeps delivering, and
cuts over once the new one’s object passes until. Use it to change layers (simulcast, ABR), or
to change a subscription’s filter or priority, which update() cannot do against moq-relay.
Handlers see only the active subscription, with its track name.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
RelayTrackOptions |
handlers? |
SwitchableHandlers |