RelayTrackWriter
Defined in: relay-sdks/ts/src/publish.ts:138
One registered track on a publisher connection, from RelayPublisher.registerTrack.
Registration sends nothing; write() and openGroup() send, after waiting for relay demand.
The behaviour behind this interface is the track’s write slot (see CONTEXT.md and the
“Write phases and interruptions” table in spec/behavior.md).
Properties
Section titled “Properties”closed
Section titled “closed”readonly closed: boolean;Defined in: relay-sdks/ts/src/publish.ts:146
True once the application closed the track or the publisher connection ended.
hasDemand
Section titled “hasDemand”readonly hasDemand: boolean;Defined in: relay-sdks/ts/src/publish.ts:144
Whether the relay currently has an upstream subscription for this track, so a write would proceed at once. Demand is the relay’s own subscription, shared by every downstream viewer and ended when the relay chooses: it is neither a viewer count nor a liveness signal. Always false once the track is closed.
Methods
Section titled “Methods”close()
Section titled “close()”close(): void;Defined in: relay-sdks/ts/src/publish.ts:185
End the track and cancel an outstanding write. The publisher connection stays open.
Returns
Section titled “Returns”void
demandChanges()
Section titled “demandChanges()”demandChanges(): AsyncIterableIterator<boolean>;Defined in: relay-sdks/ts/src/publish.ts:153
The current demand state first, then one value per relay subscription change: true when the
relay subscribes or replaces its subscription (so true can repeat), false when its
subscription ends. Ends when the track ends. This is how a catalog re-sends its document on
every relay subscription. Values are per relay subscription, never per downstream viewer.
Returns
Section titled “Returns”AsyncIterableIterator<boolean>
openGroup()
Section titled “openGroup()”openGroup(options?): Promise<RelayGroupWriter>;Defined in: relay-sdks/ts/src/publish.ts:166
Open a group and hold the track’s single write slot until it closes or aborts. Waits for relay demand, for room under the connection’s settling-group limit and for the stream, within writeTimeoutMs.
With payload, the group opens with it as object 0 and resolves once the transport takes it
(objectCount is 1). Its delivery timeout counts from this call, so every wait before the stream
opens counts (draft-22 §5.2), and a 0x02 or 0x06 property in properties sets the group’s
delivery timeouts. If it expires the call fails with DELIVERY_TIMEOUT and the group is reset.
Without payload there is no object to time, so only writeTimeoutMs bounds the wait; properties
without payload is a TypeError.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
{ payload?: ArrayBufferView<ArrayBufferLike>; properties?: readonly PublishProperty[]; signal?: AbortSignal; } |
options.payload? |
ArrayBufferView<ArrayBufferLike> |
options.properties? |
readonly PublishProperty[] |
options.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<RelayGroupWriter>
write()
Section titled “write()”write(payload, options?): Promise<void>;Defined in: relay-sdks/ts/src/publish.ts:180
Send one independent object/group. Waits for relay demand (see hasDemand). Resolves when the transport accepts the complete group, not when a downstream viewer acknowledges it. Only one write may be pending; await it before writing again. Any ArrayBufferView is copied as its raw bytes; anything else is a TypeError that leaves the track usable. Properties are encoded as supplied; the relay may transform them before delivery. Failure resets this group and leaves the track usable while the connection is open. Data may already have reached the relay; choose the next object explicitly (no automatic retry).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
payload |
ArrayBufferView |
options? |
{ properties?: readonly PublishProperty[]; signal?: AbortSignal; } |
options.properties? |
readonly PublishProperty[] |
options.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<void>
writeJSON()
Section titled “writeJSON()”writeJSON(value, options?): Promise<void>;Defined in: relay-sdks/ts/src/publish.ts:189
Serialize with JSON.stringify and write one object. Serialization errors leave the writer usable.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value |
unknown |
options? |
{ properties?: readonly PublishProperty[]; signal?: AbortSignal; } |
options.properties? |
readonly PublishProperty[] |
options.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<void>
writeText()
Section titled “writeText()”writeText(text, options?): Promise<void>;Defined in: relay-sdks/ts/src/publish.ts:187
Encode UTF-8 text and write one object with the same options and semantics as write().
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text |
string |
options? |
{ properties?: readonly PublishProperty[]; signal?: AbortSignal; } |
options.properties? |
readonly PublishProperty[] |
options.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<void>