@hyperfrontend/network-protocol/browser/sendersender
Browser-side outbound pipeline: packets in, sealed frames out.
createSender(label, sendPacket, logger, seal, onDrop?) builds a Sender from a SendPacketFn transport callback (typically target.postMessage, a WebSocket.send, or a Worker.postMessage) 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 /browser/receiver on the other end and a protocol from /browser/v3 or /browser/v4; a channel from /browser/channel creates both for you.
API Reference§
◈ Interfaces
Represents an outbound processing queue with measurable size
Properties
Sender interface for processing outbound packets
Properties
◆ Types
Factory function type for creating a Sender instance;
onDrop receives each packet the sealer rejectstype CreateSender = (label: string, sender: SendPacketFn, logger: Logger, seal: PacketSealer<T>, onDrop?: PacketDropHandler) => Sender<T>Function to send data from an origin to a target
type SendFn = (origin: string, target: string, data: Data<T>) => voidCallback invoked to transmit sealed wire bytes
type SendPacketFn = (packet: Uint8Array) => void● Variables
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.