# Interface Conn<S, CP, CS, V, I, DB>

Represents a client connection to a actor.

Manages connection-specific data and controls the connection lifecycle.

#### See

Documentation

interface Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
"[CONN_CONNECTED_SYMBOL]": boolean;
"[CONN_DRIVER_SYMBOL]"?: ConnDriver;
subscriptions: Set<string>;
get "[CONN_ACTOR_SYMBOL]"(): ActorInstance<S, CP, CS, V, I, DB>;
get "[CONN_PERSIST_RAW_SYMBOL]"(): PersistedConn<CP, CS>;
get "[CONN_PERSIST_SYMBOL]"(): PersistedConn<CP, CS>;
get "[CONN_STATE_ENABLED_SYMBOL]"(): boolean;
get id(): string;
get isHibernatable(): boolean;
get lastSeen(): number;
get params(): CP;
get state(): CS;
set state(value: CS): void;
"[CONN_HAS_CHANGES_SYMBOL]"(): boolean;
"[CONN_MARK_SAVED_SYMBOL]"(): void;
"[CONN_SEND_MESSAGE_SYMBOL]"(
message: CachedSerializer<any, any, any>,
): void;
"[CONN_SPEAKS_RIVETKIT_SYMBOL]"(): boolean;
disconnect(reason?: string): Promise<void>;
send(eventName: string, ...args: unknown[]): void;
}

#### Type Parameters

- S
- CP
- CS
- V
- I
- DB extends AnyDatabaseProvider

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:43

##### Index

### Properties

[CONN_CONNECTED_SYMBOL]
[CONN_DRIVER_SYMBOL]?
subscriptions

### Accessors

[CONN_ACTOR_SYMBOL]
[CONN_PERSIST_RAW_SYMBOL]
[CONN_PERSIST_SYMBOL]
[CONN_STATE_ENABLED_SYMBOL]
id
isHibernatable
lastSeen
params
state

### Methods

[CONN_HAS_CHANGES_SYMBOL]
[CONN_MARK_SAVED_SYMBOL]
[CONN_SEND_MESSAGE_SYMBOL]
[CONN_SPEAKS_RIVETKIT_SYMBOL]
disconnect
send

## Properties

### [CONN_CONNECTED_SYMBOL]

"[CONN_CONNECTED_SYMBOL]": boolean = false

Connections exist before being connected to an actor. If true, this connection has been connected.

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:64

### `Optional`[CONN_DRIVER_SYMBOL]

"[CONN_DRIVER_SYMBOL]"?: ConnDriver

If undefined, then nothing is connected to this.

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:55

### subscriptions

subscriptions: Set<string> = ...

- Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:44

## Accessors

### [CONN_ACTOR_SYMBOL]

- get "[CONN_ACTOR_SYMBOL]"(): ActorInstance<S, CP, CS, V, I, DB>

  #### Returns ActorInstance<S, CP, CS, V, I, DB>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:59

### [CONN_PERSIST_RAW_SYMBOL]

- get "[CONN_PERSIST_RAW_SYMBOL]"(): PersistedConn<CP, CS>

  Gets the raw persist data for serialization

  #### Returns PersistedConn<CP, CS>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:175

### [CONN_PERSIST_SYMBOL]

- get "[CONN_PERSIST_SYMBOL]"(): PersistedConn<CP, CS>

  #### Returns PersistedConn<CP, CS>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:77

### [CONN_STATE_ENABLED_SYMBOL]

- get "[CONN_STATE_ENABLED_SYMBOL]"(): boolean

  #### Returns boolean

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:85

### id

- get id(): string

  Unique identifier for the connection.

  #### Returns string

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:110

### isHibernatable

- get isHibernatable(): boolean
  `Experimental`

  If the underlying connection can hibernate.

  #### Returns boolean

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:119

### lastSeen

- get lastSeen(): number

  Timestamp of the last time the connection was seen, i.e. the last time the connection was active and checked for liveness.

  #### Returns number

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:138

### params

- get params(): CP

  #### Returns CP

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:81

### state

- get state(): CS

  Gets the current state of the connection.

  Throws an error if the state is not enabled.

  #### Returns CS

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:94
- set state(value: CS): void

  Sets the state of the connection.

  Throws an error if the state is not enabled.

  #### Parameters

  - value: CS

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:103

## Methods

### [CONN_HAS_CHANGES_SYMBOL]

- "[CONN_HAS_CHANGES_SYMBOL]"(): boolean

  Returns whether this connection has unsaved changes

  #### Returns boolean

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:161

### [CONN_MARK_SAVED_SYMBOL]

- "[CONN_MARK_SAVED_SYMBOL]"(): void

  Marks changes as saved

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:168

### [CONN_SEND_MESSAGE_SYMBOL]

- "[CONN_SEND_MESSAGE_SYMBOL]"(message: CachedSerializer<any, any, any>): void

  #### Parameters

  - message: CachedSerializer<any, any, any>

  #### Returns void

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:179

### [CONN_SPEAKS_RIVETKIT_SYMBOL]

- "[CONN_SPEAKS_RIVETKIT_SYMBOL]"(): boolean

  #### Returns boolean

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:66

### disconnect

- disconnect(reason?: string): Promise<void>

  Disconnects the client with an optional reason.

  #### Parameters

  - `Optional` reason: string

    The reason for disconnection.

  #### Returns Promise<void>

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:257

### send

- send(eventName: string, ...args: unknown[]): void

  Sends an event with arguments to the client.

  #### Parameters

  - eventName: string

    The name of the event.

  - ...args: unknown[]

    The arguments for the event.

  #### Returns void

  #### See

  Documentation

  - Defined in rivetkit-typescript/packages/rivetkit/src/actor/conn/mod.ts:206