Reassembler
Per-endpoint reassembler. Feed decoded chunks in arrival order; feed returns the complete payload once all chunks for a message have arrived.
Every field in a DecodedChunk is peer-chosen, so feed treats each chunk as untrusted: it re-checks the header invariants (a hand-built DecodedChunk never passed through decodeChunk), refuses any chunk that contradicts a message already in progress, and refuses one that would grow a message past what a single ByteArray can hold. It therefore never throws, whatever the input — a fabric receive loop must survive a hostile frame, and an escaping exception is how #1819 made a NearbySeam permanently deaf. Every refusal and eviction is logged at debug; nothing is dropped silently.
Not thread-safe — use one instance per endpoint, accessed from one coroutine.
Parameters
Cap on concurrently-incomplete messages; see DEFAULT_MAX_PENDING_MESSAGES. Must be positive.
Functions
Feed one decoded chunk. Returns the complete reassembled payload when all DecodedChunk.chunkCount chunks have arrived, or null while waiting — or null if the chunk is refused (inconsistent header, a chunkCount contradicting the message already in progress, a straggler for an evicted message, or a payload that would overflow).