Skip to content

Session

Defined in: packages/net-core/src/session.ts:73

Peer-symmetric protocol session.

Owns a FrameLink, an ExchangeRegistry for requests this side has issued, and the lifecycle that ties them together. There is no client/server type split: many protocols — RTMP, AMQP, MQTT, WebSocket, IRC — have both peers issuing and answering requests, so a client is simply a session that registers no inbound handlers and a server one that never issues requests.

Subclasses implement routeFrame to decide, per frame, whether it belongs to an outstanding exchange, is an unsolicited server message, or both.

  • EventDispatcherMapBase<Events>

In

Inbound frame type.

Out

Outbound frame type.

Events extends BaseSessionEvents

Protocol-specific event map, extending BaseSessionEvents.

Key = unknown

get buffered(): number

Defined in: packages/net-core/src/session.ts:243

Bytes received but not yet decoded.

number


get pendingExchanges(): number

Defined in: packages/net-core/src/session.ts:248

Number of outstanding exchanges, including abort tombstones.

number

[asyncDispose](): Promise<void>

Defined in: packages/net-core/src/session.ts:277

Destroys the session, so it can be used with await using.

Promise<void>


destroy(error?): void

Defined in: packages/net-core/src/session.ts:271

Tear the session down, rejecting every outstanding exchange.

Rejection happens here rather than relying on the transport emitting close, so callers are never left with promises that hang against a transport that closes silently.

unknown

Optional cause reported to outstanding exchanges.

void


end(): Promise<void>

Defined in: packages/net-core/src/session.ts:258

Half-close the outbound direction and flush pending writes.

Prefer this over destroy for protocols with a farewell command, so the peer sees an orderly shutdown.

Promise<void>


isSubscribed<K>(event, listener): boolean

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:38

Check if a callback is subscribed to a specific event.

K extends string | number | symbol

K

The event name.

Callable<Events[K]>

The callback to check.

boolean

EventDispatcherMapBase.isSubscribed


subscribe<K>(event, listener, options?): Callable | null

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23

K extends string | number | symbol

K

Callable<Events[K]>

EventDispatcherSubscribeOptions

Callable | null

EventDispatcherMapBase.subscribe


unsubscribe<K>(event, listener): void

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31

Unsubscribe a callback from a specific event.

K extends string | number | symbol

K

The event name.

Callable<Events[K]>

The callback to remove.

void

EventDispatcherMapBase.unsubscribe


wait<K>(event, options?): Promise<Events[K]>

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:45

Wait for the next occurrence of a specific event, optionally matching a predicate.

This is a convenience method that subscribes to the dispatcher, waits for the next event that matches the predicate (if provided), and then unsubscribes automatically.

K extends string | number | symbol

K

The event name to wait for.

EventDispatcherWaitOptions<Events[K]>

Optional settings including predicate and abort signal.

Promise<Events[K]>

A promise that resolves with the event arguments as an array.

EventDispatcherMapBase.wait