---
url: https://docs.moqtail.dev/ts/api/model/classes/Datagram.md
---
# Class: Datagram

Represents a unified OBJECT_DATAGRAM message.

Type bit layout (form 0b00X0XXXX):

* Bit 0 (0x01): PROPERTIES
* Bit 1 (0x02): END_OF_GROUP
* Bit 2 (0x04): ZERO_OBJECT_ID
* Bit 3 (0x08): DEFAULT_PRIORITY
* Bit 5 (0x20): STATUS

## Properties

### endOfGroup

> `readonly` **endOfGroup**: `boolean`

***

### location

> `readonly` **location**: [`Location`](Location.md)

***

### objectStatus

> `readonly` **objectStatus**: [`ObjectStatus`](../enumerations/ObjectStatus.md) | `null`

***

### payload

> `readonly` **payload**: `Uint8Array`<`ArrayBufferLike`> | `null`

***

### properties

> `readonly` **properties**: [`KeyValuePair`](KeyValuePair.md)\[] | `null`

***

### publisherPriority

> `readonly` **publisherPriority**: `number` | `null`

***

### trackAlias

> `readonly` **trackAlias**: `bigint`

***

### type

> `readonly` **type**: [`ObjectDatagramType`](../enumerations/ObjectDatagramType.md)

## Accessors

### groupId

#### Get Signature

> **get** **groupId**(): `bigint`

##### Returns

`bigint`

***

### objectId

#### Get Signature

> **get** **objectId**(): `bigint`

##### Returns

`bigint`

## Methods

### serialize()

> **serialize**(): [`FrozenByteBuffer`](FrozenByteBuffer.md)

#### Returns

[`FrozenByteBuffer`](FrozenByteBuffer.md)

***

### deserialize()

> `static` **deserialize**(`buf`): `Datagram`

#### Parameters

##### buf

[`BaseByteBuffer`](BaseByteBuffer.md)

#### Returns

`Datagram`

***

### newPayload()

> `static` **newPayload**(`trackAlias`, `groupId`, `objectId`, `publisherPriority`, `properties`, `payload`, `endOfGroup?`): `Datagram`

Create a new Datagram with payload content.
The type is automatically determined based on the properties.

#### Parameters

##### trackAlias

`bigint`

##### groupId

`bigint`

##### objectId

`bigint`

##### publisherPriority

`number` | `null`

##### properties

[`KeyValuePair`](KeyValuePair.md)\[] | `null`

##### payload

`Uint8Array`

##### endOfGroup?

`boolean` = `false`

#### Returns

`Datagram`

***

### newStatus()

> `static` **newStatus**(`trackAlias`, `groupId`, `objectId`, `publisherPriority`, `properties`, `objectStatus`): `Datagram`

Create a new Datagram with Object Status (no payload).
endOfGroup is always false since STATUS + END_OF_GROUP is invalid.

#### Parameters

##### trackAlias

`bigint`

##### groupId

`bigint`

##### objectId

`bigint`

##### publisherPriority

`number` | `null`

##### properties

[`KeyValuePair`](KeyValuePair.md)\[] | `null`

##### objectStatus

[`ObjectStatus`](../enumerations/ObjectStatus.md)

#### Returns

`Datagram`
