# RelayGroupWriter

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

Defined in: [relay-sdks/ts/src/publish.ts:96](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L96)

One open group from [RelayTrackWriter.openGroup](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/relaytrackwriter/#opengroup): a single subgroup stream the application
writes objects to in order, then FINs with `close()` or resets with `abort()`. It holds the track's
write slot until then, so the track's `write()` and another `openGroup()` fail with `WRITE_PENDING` meanwhile.

## Properties

### closed

```ts
readonly closed: boolean;
```

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

True once `close()` completed, or the group was aborted, failed, or lost its track or connection.

***

### groupId

```ts
readonly groupId: number;
```

Defined in: [relay-sdks/ts/src/publish.ts:98](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L98)

The group's ID. Group IDs start at 0 on each track and increase by one per group the track opens.

***

### objectCount

```ts
readonly objectCount: number;
```

Defined in: [relay-sdks/ts/src/publish.ts:100](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L100)

How many objects this group has written; the next `write()` uses it as the object ID.

## Methods

### abort()

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

Defined in: [relay-sdks/ts/src/publish.ts:122](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L122)

Reset this group and free the track for the next random-access point. After a clean `close()`
this has no effect: the FIN already ended the stream (draft-22 §11.3.2).

#### Parameters

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

#### Returns

`void`

***

### close()

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

Defined in: [relay-sdks/ts/src/publish.ts:117](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L117)

FIN the group within writeTimeoutMs. Resolves once the FIN is handed to the transport, not once
the relay acknowledges it. Idempotent after successful completion.

#### Returns

`Promise`\<`void`\>

***

### write()

```ts
write(payload, options?): Promise<void>;
```

Defined in: [relay-sdks/ts/src/publish.ts:109](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L109)

Append one object, starting at ID 0. Each write has its own writeTimeoutMs deadline, and a
delivery timeout can end it sooner with `DELIVERY_TIMEOUT`, which resets the whole group.
Properties are encoded as supplied; the relay may transform them before delivery. A `0x02` or
`0x06` property on object 0 sets the group's delivery timeouts; on a later object it is ignored.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `payload` | `ArrayBufferView` |
| `options?` | \{ `properties?`: readonly [`PublishProperty`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishproperty/)[]; `status?`: [`ObjectStatus`](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/type-aliases/objectstatus/); \} |
| `options.properties?` | readonly [`PublishProperty`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishproperty/)[] |
| `options.status?` | [`ObjectStatus`](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/type-aliases/objectstatus/) |

#### Returns

`Promise`\<`void`\>

***

### writeJSON()

```ts
writeJSON(value, options?): Promise<void>;
```

Defined in: [relay-sdks/ts/src/publish.ts:126](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L126)

Serialize with JSON.stringify and write one object. Serialization errors leave the writer usable.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `value` | `unknown` |
| `options?` | \{ `properties?`: readonly [`PublishProperty`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishproperty/)[]; `status?`: [`ObjectStatus`](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/type-aliases/objectstatus/); \} |
| `options.properties?` | readonly [`PublishProperty`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishproperty/)[] |
| `options.status?` | [`ObjectStatus`](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/type-aliases/objectstatus/) |

#### Returns

`Promise`\<`void`\>

***

### writeText()

```ts
writeText(text, options?): Promise<void>;
```

Defined in: [relay-sdks/ts/src/publish.ts:124](https://github.com/caprids/relay-sdks/blob/main/ts/src/publish.ts#L124)

Encode UTF-8 text and write one object with the same options and semantics as write().

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `text` | `string` |
| `options?` | \{ `properties?`: readonly [`PublishProperty`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishproperty/)[]; `status?`: [`ObjectStatus`](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/type-aliases/objectstatus/); \} |
| `options.properties?` | readonly [`PublishProperty`](https://www.caprid.com/docs/reference/typescript/caprid/relay/index/interfaces/publishproperty/)[] |
| `options.status?` | [`ObjectStatus`](https://www.caprid.com/docs/reference/typescript/caprid/moq-core/index/type-aliases/objectstatus/) |

#### Returns

`Promise`\<`void`\>
