---
url: https://docs.moqtail.dev/ts/api/client/classes/SubscribePublication.md
---
# Class: SubscribePublication

Manages the publication of MOQT objects to a subscriber for a specific track.
Handles live object streaming, subscription lifecycle, and stream management.

## Constructors

### Constructor

> **new SubscribePublication**(`client`, `track`, `subscribeMsg`, `requestStream`, `largestLocation?`): `SubscribePublication`

Creates a new SubscribePublication instance.

#### Parameters

##### client

[`MOQtailClient`](MOQtailClient.md)

The MOQT client managing the subscription.

##### track

[`Track`](../type-aliases/Track.md)

The track being published.

##### subscribeMsg

[`Subscribe`](../../model/classes/Subscribe.md)

The subscribe message containing subscription details.

##### requestStream

[`RequestStream`](RequestStream.md)

The bidi request stream the SUBSCRIBE arrived on. Every
message this publication sends back to the subscriber goes on it.

##### largestLocation?

[`Location`](../../model/classes/Location.md)

The largest location seen so far, used for determining start location.

#### Returns

`SubscribePublication`

## Properties

### latestLocation

> **latestLocation**: [`Location`](../../model/classes/Location.md) | `undefined`

The latest location that was published to the subscriber.

***

### track

> `readonly` **track**: [`Track`](../type-aliases/Track.md)

The track being published.

## Methods

### cancel()

> **cancel**(): `void`

Cancels the publication and cleans up resources.
Removes the publication from the client's publication map.

#### Returns

`void`

***

### done()

> **done**(`statusCode`): `Promise`<`void`>

Marks the publication as done and sends a PublishDone message to the client.

#### Parameters

##### statusCode

[`PublishDoneStatusCode`](../../model/enumerations/PublishDoneStatusCode.md)

The status code indicating why the publication ended.

#### Returns

`Promise`<`void`>

#### Throws

:[InternalError](../../model/classes/InternalError.md) If sending the message fails.

***

### publish()

> **publish**(): `Promise`<`void`>

Publishes MOQT objects to the subscriber as they become available.
Handles stream creation, object writing, and stream closure based on subscription parameters.

#### Returns

`Promise`<`void`>

#### Throws

:[InternalError](../../model/classes/InternalError.md) If the track does not support live content.

***

### update()

> **update**(`msg`): `void`

Updates the subscription parameters and locations based on a RequestUpdate message.

#### Parameters

##### msg

[`RequestUpdate`](../../model/classes/RequestUpdate.md)

The update message containing new request details.

#### Returns

`void`

#### Throws

:`InvalidFilterError` If the Range Filters the subscription would be
left with cannot be applied; nothing is updated.
