FrameLink
Defined in: packages/net-core/src/frame-link.ts:111
Turns a byte Transport into a stream of typed values, and typed values back into bytes.
Owns everything that is protocol-independent: the decode loop (via
DecodeDriver), streamed payloads (via BodyReader), read and write
backpressure, silence timeouts, transport and codec swapping, and lifecycle.
Protocol knowledge lives entirely in the injected Codec, and
correlation lives entirely above in the session.
Message-mode datagrams bypass the decode loop entirely — a datagram is always
exactly one complete value with no state carried to the next one, which
DecodeDriver (built for accumulation across calls) has nothing to offer.
Extends
Section titled “Extends”EventDispatcherMapBase<FrameLinkEvents>
Type Parameters
Section titled “Type Parameters”In
Decoded (inbound) value type.
Out = In
Encoded (outbound) value type. Separate from In because
most non-trivial protocols are asymmetric.
Implements
Section titled “Implements”IEventDispatcherMap<FrameLinkEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FrameLink<
In,Out>(options):FrameLink<In,Out>
Defined in: packages/net-core/src/frame-link.ts:128
Parameters
Section titled “Parameters”options
Section titled “options”FrameLinkOptions<In, Out>
Returns
Section titled “Returns”FrameLink<In, Out>
Overrides
Section titled “Overrides”EventDispatcherMapBase<FrameLinkEvents>.constructor
Accessors
Section titled “Accessors”buffered
Section titled “buffered”Get Signature
Section titled “Get Signature”get buffered():
number
Defined in: packages/net-core/src/frame-link.ts:173
Bytes received but not yet decoded.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”[asyncDispose]():
Promise<void>
Defined in: packages/net-core/src/frame-link.ts:350
Destroys the link, so it can be used with await using.
Returns
Section titled “Returns”Promise<void>
destroy()
Section titled “destroy()”destroy(
error?):void
Defined in: packages/net-core/src/frame-link.ts:337
Tear down the link and its transport.
Parameters
Section titled “Parameters”error?
Section titled “error?”unknown
Optional cause reported to listeners.
Returns
Section titled “Returns”void
detach()
Section titled “detach()”detach():
Transport
Defined in: packages/net-core/src/frame-link.ts:311
Release the transport to another protocol, keeping every byte received but not yet decoded.
This is the HTTP Upgrade primitive: once the 101 is decoded or sent,
the connection is no longer HTTP, and the bytes that arrived in the same
segment belong to the next protocol. Safe to call from inside a
FrameSink invocation; no value is decoded afterwards. The link emits
no further event, close included — the connection is still open, it just
is not this link’s anymore.
Stream mode only. A body still being streamed is errored.
Returns
Section titled “Returns”The transport, paused and stopped. Its first delivery to the next owner is the undecoded bytes; starting it resumes the flow.
Throws
Section titled “Throws”When the link is already closed or detached.
end():
Promise<void>
Defined in: packages/net-core/src/frame-link.ts:289
Half-close the outbound direction and flush pending writes.
Returns
Section titled “Returns”Promise<void>
Resolves once the transport has flushed.
isSubscribed()
Section titled “isSubscribed()”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.
Type Parameters
Section titled “Type Parameters”K extends keyof FrameLinkEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<FrameLinkEvents[K]>
The callback to check.
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”IEventDispatcherMap.isSubscribed
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.isSubscribed
pause()
Section titled “pause()”pause():
void
Defined in: packages/net-core/src/frame-link.ts:210
Suspend value delivery by pausing the transport.
Returns
Section titled “Returns”void
reset()
Section titled “reset()”reset():
void
Defined in: packages/net-core/src/frame-link.ts:226
Discard undecoded bytes, decoder state and any silence timer.
Safe to call from inside a FrameSink invocation: DecodeDriver
detects the reentrant call and stops rather than continuing over a buffer
that no longer exists.
Returns
Section titled “Returns”void
resume()
Section titled “resume()”resume():
void
Defined in: packages/net-core/src/frame-link.ts:215
Resume value delivery suspended by pause.
Returns
Section titled “Returns”void
send()
Section titled “send()”send(
value,signal?):Promise<void>
Defined in: packages/net-core/src/frame-link.ts:185
Encode and send one value.
Parameters
Section titled “Parameters”Out
The value to transmit.
signal?
Section titled “signal?”AbortSignal
Cancels the wait for transport capacity. Bytes already accepted by the transport cannot be unsent.
Returns
Section titled “Returns”Promise<void>
Resolves once the transport has accepted the bytes.
sendRaw()
Section titled “sendRaw()”sendRaw(
data,signal?):Promise<void>
Defined in: packages/net-core/src/frame-link.ts:199
Send raw bytes, bypassing the encoder.
Required by protocols that interleave opaque payloads with framed commands,
such as an SMTP DATA body.
Parameters
Section titled “Parameters”Uint8Array<ArrayBufferLike> | readonly Uint8Array<ArrayBufferLike>[]
One or more buffers, written as a single vectored write.
signal?
Section titled “signal?”AbortSignal
Cancels the wait for transport capacity.
Returns
Section titled “Returns”Promise<void>
Resolves once the transport has accepted the bytes.
subscribe()
Section titled “subscribe()”subscribe<
K>(event,listener,options?):Callable|null
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23
Type Parameters
Section titled “Type Parameters”K extends keyof FrameLinkEvents
Parameters
Section titled “Parameters”K
listener
Section titled “listener”Callable<FrameLinkEvents[K]>
options?
Section titled “options?”EventDispatcherSubscribeOptions
Returns
Section titled “Returns”Callable | null
Implementation of
Section titled “Implementation of”IEventDispatcherMap.subscribe
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.subscribe
swapCodec()
Section titled “swapCodec()”swapCodec(
codec):void
Defined in: packages/net-core/src/frame-link.ts:250
Replace the codec, for example after an RTMP handshake completes or an SMTP session negotiates a new mode.
Parameters
Section titled “Parameters”Codec<In, Out>
The codec to decode and encode with from now on.
Returns
Section titled “Returns”void
swapTransport()
Section titled “swapTransport()”swapTransport(
transport,options?):void
Defined in: packages/net-core/src/frame-link.ts:267
Replace the transport, carrying over any undecoded bytes.
This is the STARTTLS primitive: the plaintext transport is detached (not destroyed, since the TLS transport wraps the same socket) and framing continues over the new one.
Parameters
Section titled “Parameters”transport
Section titled “transport”The transport to read from and write to from now on.
options?
Section titled “options?”keepResidue retains undecoded bytes across the swap. Leave
it false for security-sensitive switches such as STARTTLS, where
buffered plaintext is a command-injection vector.
Returns
Section titled “Returns”void
takeResidue()
Section titled “takeResidue()”takeResidue():
Uint8Array
Defined in: packages/net-core/src/frame-link.ts:240
Remove and return the undecoded bytes without discarding them.
The residue after a protocol switch belongs to the next protocol: an HTTP
Upgrade response may be followed immediately by WebSocket bytes in the
same segment. Discarding them silently corrupts the upgraded connection.
Returns
Section titled “Returns”Uint8Array
A copy of the bytes received but not yet decoded.
unsubscribe()
Section titled “unsubscribe()”unsubscribe<
K>(event,listener):void
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31
Unsubscribe a callback from a specific event.
Type Parameters
Section titled “Type Parameters”K extends keyof FrameLinkEvents
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<FrameLinkEvents[K]>
The callback to remove.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IEventDispatcherMap.unsubscribe
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.unsubscribe
wait()
Section titled “wait()”wait<
K>(event,options?):Promise<FrameLinkEvents[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.
Type Parameters
Section titled “Type Parameters”K extends keyof FrameLinkEvents
Parameters
Section titled “Parameters”K
The event name to wait for.
options?
Section titled “options?”EventDispatcherWaitOptions<FrameLinkEvents[K]>
Optional settings including predicate and abort signal.
Returns
Section titled “Returns”Promise<FrameLinkEvents[K]>
A promise that resolves with the event arguments as an array.
Implementation of
Section titled “Implementation of”IEventDispatcherMap.wait
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.wait