# SubscriptionHandlers

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

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:80

Callbacks for [MoqtSession.subscribe](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/interfaces/moqtsession/#subscribe). Each must be synchronous; an async function throws `TypeError`.

## Methods

### onDone()?

```ts
onDone?(done): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:102

PUBLISH_DONE arrived. Subgroup streams already in flight still deliver until the subscription is cancelled.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `done` | [`PublishDone`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishdone/) |

#### Returns

`void`

***

### onError()?

```ts
onError?(error): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:84

The subscription failed before or instead of SUBSCRIBE_OK: REQUEST_ERROR, or a stream failure.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `error` | [`RequestError`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/requesterror/) |

#### Returns

`void`

***

### onGoaway()?

```ts
onGoaway?(goaway): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:111

GOAWAY on this request stream: re-issue the request (possibly elsewhere).

#### Parameters

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

#### Returns

`void`

***

### onObject()?

```ts
onObject?(object): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:86

An object arrived on one of the subscription's subgroup streams.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `object` | [`MoqtObject`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/moqtobject/) |

#### Returns

`void`

***

### onOk()?

```ts
onOk?(ok): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:82

SUBSCRIBE_OK arrived.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `ok` | [`SubscribeOk`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscribeok/) |

#### Returns

`void`

***

### onStateNotify()?

```ts
onStateNotify?(parameters): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:109

PUBLISH_STATE_NOTIFY (§9.10): the publisher changed subscription state on its own — `parameters` carries only what
changed, with LARGEST_OBJECT marking where. Informational; the session sends no reply.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `parameters` | [`MessageParameters`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/messageparameters/) |

#### Returns

`void`

***

### onSubgroupEnd()?

```ts
onSubgroupEnd?(info): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:88

A subgroup stream finished cleanly (FIN).

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | \{ `endOfGroup`: `boolean`; `groupId`: `number`; `subgroupId`: `number`; \} |
| `info.endOfGroup` | `boolean` |
| `info.groupId` | `number` |
| `info.subgroupId` | `number` |

#### Returns

`void`

***

### onSubgroupReset()?

```ts
onSubgroupReset?(info): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:97

A subgroup stream was reset — objects from it may be missing. Reported for every reset the session receives; a
relay that drops a reset instead of forwarding it leaves nothing to report.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `info` | \{ `error`: `unknown`; `groupId`: `number`; \} |
| `info.error` | `unknown` |
| `info.groupId` | `number` |

#### Returns

`void`

***

### onUpdateOk()?

```ts
onUpdateOk?(): void;
```

Defined in: relay-sdks/ts/packages/moq-core/dist/protocol/session.d.ts:104

Response to a REQUEST_UPDATE sent on this subscription.

#### Returns

`void`
