# SubscriptionEvent

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/subscriptionevent/

```ts
type SubscriptionEvent = 
  | {
  type: "subscribed";
  value: SubscribeOk;
}
  | {
  type: "object";
  value: MoqtObject;
}
  | {
  type: "publisherDone";
  value: PublishDone;
}
  | {
  type: "subgroupEnd";
  value: {
     endOfGroup: boolean;
     groupId: number;
     subgroupId: number;
  };
}
  | {
  type: "subgroupReset";
  value: {
     error: unknown;
     groupId: number;
  };
}
  | {
  type: "stateNotify";
  value: MessageParameters;
}
  | {
  type: "goaway";
  value: Goaway;
}
  | {
  type: "updateOk";
  value: undefined;
};
```

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

Delivery order is callback arrival order, with no ordering guarantee across streams.

## Union Members

### Type Literal

```ts
{
  type: "subscribed";
  value: SubscribeOk;
}
```

#### type

```ts
type: "subscribed";
```

The relay accepted the subscription (SUBSCRIBE_OK).

#### value

```ts
value: SubscribeOk;
```

The acceptance info `onSubscribed` receives.

***

### Type Literal

```ts
{
  type: "object";
  value: MoqtObject;
}
```

#### type

```ts
type: "object";
```

One object arrived, including an object that carries only a protocol status.

#### value

```ts
value: MoqtObject;
```

The object; its payload is uninterpreted bytes.

***

### Type Literal

```ts
{
  type: "publisherDone";
  value: PublishDone;
}
```

#### type

```ts
type: "publisherDone";
```

The publisher finished with the track (PUBLISH_DONE). Not an ending: trailing objects can follow.

#### value

```ts
value: PublishDone;
```

The done's status, stream count and reason.

***

### Type Literal

```ts
{
  type: "subgroupEnd";
  value: {
     endOfGroup: boolean;
     groupId: number;
     subgroupId: number;
  };
}
```

#### type

```ts
type: "subgroupEnd";
```

A subgroup stream finished cleanly (FIN); only that subgroup ended.

#### value

```ts
value: object;
```

Which subgroup ended.

##### value.endOfGroup

```ts
endOfGroup: boolean;
```

Whether the subgroup's header marked it as holding the group's largest object.

##### value.groupId

```ts
groupId: number;
```

The group the subgroup belongs to.

##### value.subgroupId

```ts
subgroupId: number;
```

The subgroup that ended.

***

### Type Literal

```ts
{
  type: "subgroupReset";
  value: {
     error: unknown;
     groupId: number;
  };
}
```

#### type

```ts
type: "subgroupReset";
```

A subgroup stream was reset; objects from it may be missing. Delivery continues.

#### value

```ts
value: object;
```

Which group the reset stream carried, and why it failed.

##### value.error

```ts
error: unknown;
```

The transport's stream error, as the runtime reported it.

##### value.groupId

```ts
groupId: number;
```

The group the reset subgroup belongs to.

***

### Type Literal

```ts
{
  type: "stateNotify";
  value: MessageParameters;
}
```

#### type

```ts
type: "stateNotify";
```

The publisher changed subscription state on its own (PUBLISH_STATE_NOTIFY).

#### value

```ts
value: MessageParameters;
```

Only the parameters that changed.

***

### Type Literal

```ts
{
  type: "goaway";
  value: Goaway;
}
```

#### type

```ts
type: "goaway";
```

The relay sent GOAWAY on this request. Informational; the SDK does not retry.

#### value

```ts
value: Goaway;
```

The relay's suggested new session URI (may be empty) and timeout.

***

### Type Literal

```ts
{
  type: "updateOk";
  value: undefined;
}
```

#### type

```ts
type: "updateOk";
```

The relay acknowledged an `update()` (REQUEST_OK).

#### value

```ts
value: undefined;
```

Always `undefined`; the acknowledgment carries nothing.
