Skip to content

Class: SessionHub

Defined in: packages/aiui-claude-channel/src/session-hub.ts:141

The channel's live session bus: the connected views and the shared state they agree on. One instance per channel process; shared by the /session websocket (which feeds it) and /health (which summarizes it).

Constructors

Constructor

new SessionHub(options?): SessionHub

Defined in: packages/aiui-claude-channel/src/session-hub.ts:148

Parameters

options?

SessionHubOptions = {}

Returns

SessionHub

Methods

addConnection()

addConnection(send): string

Defined in: packages/aiui-claude-channel/src/session-hub.ts:157

Register a freshly connected session socket; returns its server-assigned id. The peer is not announced until its hello arrives (so the peer list carries role/label).

Parameters

send

SessionSend

Returns

string


get()

get(slot): unknown

Defined in: packages/aiui-claude-channel/src/session-hub.ts:237

The current value of one shared-state slot, if set (server-side reads).

Parameters

slot

string

Returns

unknown


handleClientMessage()

handleClientMessage(clientId, raw): void

Defined in: packages/aiui-claude-channel/src/session-hub.ts:183

Dispatch one parsed client message. Validates loosely — a malformed message is ignored rather than fatal (cooperative same-host client).

Parameters

clientId

string

raw

unknown

Returns

void


peers()

peers(): SessionPeerInfo[]

Defined in: packages/aiui-claude-channel/src/session-hub.ts:242

The greeted peers, for external listing (GET /session/peers).

Returns

SessionPeerInfo[]


publishFromServer()

publishFromServer(topic, payload, target?): SessionPeerInfo[]

Defined in: packages/aiui-claude-channel/src/session-hub.ts:255

A server-originated publish: an external same-host tool (the VS Code extension, a CLI) contributing to the session through the web backend instead of holding a /session socket of its own. Targets one view by clientId, every greeted view with role, or — no target — every greeted view. Returns the peers actually sent to, so the HTTP caller can be told whether anything was reachable (from is "server", which can never collide with a connection id — those are UUIDs).

Parameters

topic

string

payload

unknown

target?
clientId?

string

role?

string

Returns

SessionPeerInfo[]


removeConnection()

removeConnection(clientId): void

Defined in: packages/aiui-claude-channel/src/session-hub.ts:169

Drop a connection and tell everyone else the peer list shrank.

Parameters

clientId

string

Returns

void


summary()

summary(): SessionSummary

Defined in: packages/aiui-claude-channel/src/session-hub.ts:312

Cheap counts for a /health or /debug summary.

Returns

SessionSummary