# RelaySubscription

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

Defined in: [relay-sdks/ts/src/subscription.ts:138](https://github.com/caprids/relay-sdks/blob/main/ts/src/subscription.ts#L138)

The handle `RelaySubscriber.subscribe()` returns: the core handle plus readiness and termination.

## Extends

- [`Subscription`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/)

## Properties

### ended

```ts
readonly ended: Promise<SubscriptionEnd>;
```

Defined in: [relay-sdks/ts/src/subscription.ts:152](https://github.com/caprids/relay-sdks/blob/main/ts/src/subscription.ts#L152)

Settles once, when the subscription can no longer deliver, with how it ended. Never rejects.
Publisher completion (`onPublisherDone`) is not an ending: trailing objects can still arrive,
and the request stays open until `cancel()` or the connection ends. Neither awaitable implies
exactly-once or gap-free delivery.

***

### requestId

```ts
readonly requestId: number;
```

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

Request ID of the SUBSCRIBE.

#### Inherited from

[`Subscription`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/).[`requestId`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/#requestid)

***

### subscribed

```ts
readonly subscribed: Promise<SubscribeOk>;
```

Defined in: [relay-sdks/ts/src/subscription.ts:145](https://github.com/caprids/relay-sdks/blob/main/ts/src/subscription.ts#L145)

Settles when the relay answers. Resolves with the acceptance info `onSubscribed` receives.
Rejects with [SubscriptionRequestError](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/classes/subscriptionrequesterror/) when the relay rejected the request or it timed
out, [SubscriptionConnectionClosedError](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/classes/subscriptionconnectionclosederror/) when the connection ended first, or the reason
given to `cancel()` (a `CLOSED` RelayError when none was given). Never rejects after acceptance.

## Methods

### cancel()

```ts
cancel(reason?): void;
```

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

Tear the subscription down. MOQT has no UNSUBSCRIBE message — teardown is the request stream's lifecycle (§6.4.2.3).

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `reason?` | `unknown` |

#### Returns

`void`

#### Inherited from

[`Subscription`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/).[`cancel`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/#cancel)

***

### update()

```ts
update(parameters): void;
```

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

Modify the subscription (REQUEST_UPDATE, §9.5).

#### Parameters

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

#### Returns

`void`

#### Inherited from

[`Subscription`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/).[`update`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/subscription/#update)
