# SupervisedPublisher

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/supervisedpublisher/

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:78](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L78)

A publisher that reconnects. Create one with [connectSupervisedPublisher](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/functions/connectsupervisedpublisher/). Each connection is a new
generation with its own namespace; tracks are registered once and rebound to every generation.

## Properties

### closed

```ts
readonly closed: Promise<{
  error?: unknown;
}>;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:92](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L92)

Resolves once the supervisor stops: `close()`, the signal, or a failure it does not retry. Never rejects.

***

### generation

```ts
readonly generation: 
  | PublisherGeneration
  | undefined;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:80](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L80)

The live generation, or `undefined` between connections and after closing.

***

### status

```ts
readonly status: SupervisedStatus;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:82](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L82)

Where the supervisor stands; see [SupervisedStatus](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/supervisedstatus/).

## Methods

### close()

```ts
close(): Promise<void>;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:104](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L104)

Stop reconnecting and close the live generation as `RelayPublisher.close()` does. Idempotent.

#### Returns

`Promise`\<`void`\>

***

### registerTrack()

```ts
registerTrack(options): RelayTrackWriter;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:90](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L90)

Register a track every generation serves, and return the writer that outlives the generations. The same rules as
`RelayPublisher.registerTrack`, checked at once: track names are unique per supervised publisher, including after
their writer closes. Writes wait for demand on the live generation; while none is up they fail with
`RECONNECTING`, and an operation the connection's end interrupts fails with `RECONNECTING` too, never `CLOSED`, so
a frame writer treats it as an interruption and resumes at the next keyframe.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options` | [`RegisterTrackOptions`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/registertrackoptions/) |

#### Returns

[`RelayTrackWriter`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/relaytrackwriter/)

***

### rotate()

```ts
rotate(): void;
```

Defined in: [relay-sdks/ts/src/supervised-publisher.ts:102](https://github.com/caprids/relay-sdks/blob/main/ts/src/supervised-publisher.ts#L102)

Replace the live generation make-before-break, as happens on its own `rotateBeforeMs` before the credential
expires: the next generation connects, with a fresh token, and every track is registered on it. Each track's
writer then moves to it at its next write or group, once the track has demand there or has none on the old one.
The old generation closes once every track has moved, after 10 seconds at most. A no-op while no generation is up.

#### Returns

`void`
