@hyperfrontend/network-protocol/node/sender

sender

Node.js-side outbound pipeline: packets in, sealed frames out.

createSender(label, sendPacket, logger, seal, onDrop?) builds a Sender from a SendPacketFn transport callback (typically a TCP socket write, a process.send IPC call, or a WebSocket.send) and the session's PacketSealer (protocol.seal). sender.send(origin, target, data) validates the packet synchronously, then a single seal queue produces each wire frame in order and hands it to the callback; a packet the sealer rejects is reported through onDrop rather than thrown. The sender exposes stop, resume, and queue.size for backpressure. Pair with /node/receiver on the other end and a protocol from /node/v3 or /node/v4; a channel from /node/channel creates both for you.

Function signatures match /browser/sender so cross-runtime communication is symmetric.

API Reference§

Interfaces

§interface

OutboundQueue

Represents an outbound processing queue with measurable size

Properties

§readonly size:number
Number of items in the queue
§interface

Sender

Sender interface for processing outbound packets

Properties

§readonly queue:OutboundQueue
The packets waiting to be sealed
§readonly resume:() => void
Resumes packet processing
§readonly send:SendFn<T>
Sends data from origin to target
§readonly stop:() => void
Pauses packet processing

Types

§type

CreateSender

Factory function type for creating a Sender instance; onDrop receives each packet the sealer rejects
type CreateSender = (label: string, sender: SendPacketFn, logger: Logger, seal: PacketSealer<T>, onDrop?: PacketDropHandler) => Sender<T>
§type

SenderFactory

Alias for CreateSender factory type
type SenderFactory = CreateSender
§type

SendFn

Function to send data from an origin to a target
type SendFn = (origin: string, target: string, data: Data<T>) => void
§type

SendPacketFn

Callback invoked to transmit sealed wire bytes
type SendPacketFn = (packet: Uint8Array) => void

Variables

§type

createSender

Creates the outbound half of a channel: packets are assembled, sealed one at a time on the session's sending key, and handed to the transport as wire bytes.
send validates the origin, target, and data envelope synchronously and throws in the caller's frame on a malformed packet; everything after that is asynchronous, and a packet the sealer rejects is reported through onDrop rather than thrown.