@hyperfrontend/network-protocol/node/receiver

receiver

Node.js-side inbound pipeline: frames in, opened packets out.

createReceiver(label, receivePacket, logger, open, onDrop?) builds a Receiver from a ReceivePacketFn callback that takes each opened UnencryptedPacket and the session's PacketOpener (protocol.open). receiver.receive(frame) takes the raw bytes from a TCP socket data event, a process.on('message', ...) IPC handler, or a WebSocket message handler; a single open queue opens one frame at a time, which keeps the session's replay counter exact, and delivers each packet in order. A frame that is forged, replayed, malformed, or from another session is reported through onDrop and never delivered.

Hello frames belong to the protocol's acceptHello, not to the receiver. Pair with /node/sender 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/receiver so cross-runtime communication is symmetric.

API Reference§

Interfaces

§interface

InboundQueue

Represents an inbound processing queue with measurable size

Properties

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

Receiver

Receiver interface for processing inbound frames

Properties

§readonly queue:InboundQueue
The frames waiting to be opened
§readonly receive:ReceiveFn
Feeds an incoming frame into the pipeline
§readonly resume:() => void
Resumes frame processing
§readonly stop:() => void
Pauses frame processing

Types

§type

CreateReceiver

Factory function type for creating a Receiver instance; onDrop receives each frame the opener rejects
type CreateReceiver = (label: string, receiver: ReceivePacketFn<T>, logger: Logger, open: PacketOpener<T>, onDrop?: PacketDropHandler) => Receiver
§type

ReceiveFn

Function to receive raw wire bytes
type ReceiveFn = (packet: Uint8Array) => void
§type

ReceivePacketFn

Callback invoked with each opened packet
type ReceivePacketFn = (packet: UnencryptedPacket<T>) => void
§type

ReceiverFactory

Alias for CreateReceiver factory type
type ReceiverFactory = CreateReceiver

Variables

§type

createReceiver

Creates the inbound half of a channel: frames are opened one at a time on the session's receiving key and delivered as plaintext packets.
A frame the opener rejects (forged, replayed, foreign, or malformed) is reported through onDrop and never delivered.