Skip to content

FeatureContext

Defined in: src/features/feature.ts:23

The controlled slice of a session a feature module may touch. Every shared capability is injected here per-session — the transport-facing helpers, the ports (events, log, admin) and model (state), plus the per-session mutable feature state in rt. Nothing is reached via module-level singletons.

readonly admin: AdminSessionStore;

Defined in: src/features/feature.ts:44

Repeater admin auth + pending-request store (was adminSessions).


readonly events: Events;

Defined in: src/features/feature.ts:38

Event bus the feature broadcasts on (was the module-level emit).


readonly log: Logger;

Defined in: src/features/feature.ts:42

Structured logger (was child('protocol')).


readonly rt: SessionRuntime;

Defined in: src/features/feature.ts:46

Per-session mutable feature state (replaces module-level let/const).


readonly state: SessionState;

Defined in: src/features/feature.ts:40

In-memory session model the feature reads & mutates (was stateHolder()).

contactsSync(signal): void;

Defined in: src/features/feature.ts:52

INTERNAL contact-sync signal sink (was the module-level emit.contactsSync). The session implements this to drive the handshake’s syncProgress + start/done waiters; it is NOT a public event.

ParameterType
signalContactsSyncSignal

void


getTransportState(): TransportState;

Defined in: src/features/feature.ts:48

Current transport connection state (replaces transportManager.getState()).

TransportState


request(frame, opts?): Promise<Buffer<ArrayBufferLike>>;

Defined in: src/features/feature.ts:29

Send a frame and await its reply. With expect, resolves the next inbound frame whose code === expect (a typed GET reply). Without expect, awaits the next RESP_OK/RESP_ERR and rejects with ProtocolError on RESP_ERR.

ParameterType
frameBuffer
opts?{ expect?: number; timeoutMs?: number; }
opts.expect?number
opts.timeoutMs?number

Promise<Buffer<ArrayBufferLike>>


requestOrNull(
frame,
expect,
timeoutMs?): Promise<Buffer<ArrayBufferLike> | null>;

Defined in: src/features/feature.ts:36

Send a frame and await either its typed reply (code === expect) OR a RESP_ERR — for GETs that legitimately answer “not found” (e.g. no cached advert path). Resolves the typed frame, or null on RESP_ERR. The RESP_ERR is consumed via the shared ack FIFO so it can’t be mistaken for a rejected DM send. Rejects on timeout / write failure / disconnect. expect must be a typed reply code, not RESP_OK/RESP_ERR.

ParameterType
frameBuffer
expectnumber
timeoutMs?number

Promise<Buffer<ArrayBufferLike> | null>


writeFrame(frame): Promise<void>;

Defined in: src/features/feature.ts:25

Write a raw companion frame to the radio.

ParameterType
frameBuffer

Promise<void>