RemotePacketStream

class RemotePacketStream(val address: RemoteAddress, limits: RemoteLimits = RemotePacket.limits, send: (ByteArray) -> Unit) : AutoCloseable(source)

Execution-owner-confined ordering boundary for one host incarnation across asynchronous proxy message events. Retains at most the negotiated pending bytes and entry count; gaps expire on monotonic adapter ticks. Screen cancellation occupies its ordinary ordered frame position, so dropped transfers cannot leave sequence gaps. Terminal close releases all queued bytes and the native writer.

Constructors

Link copied to clipboard
constructor(address: RemoteAddress, limits: RemoteLimits = RemotePacket.limits, send: (ByteArray) -> Unit)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun drain(nowMillis: Long, maxFrames: Int = 64, receive: (ByteArray) -> Unit)

Delivers at most maxFrames consecutive fragments, stopping at the first missing sequence. Checks deadlines before delivery and records the remaining gap after delivery, even without new input.

Link copied to clipboard
fun limitTo(negotiated: RemoteLimits)

Tightens admission after negotiation, rejecting already queued work that exceeds the negotiated bounds.

Link copied to clipboard
fun offer(packet: RemotePacket.Frame, nowMillis: Long)

Copies a current-incarnation fragment into the bounded reorder queue; stale incarnations and duplicates are ignored. Conflicting duplicate content, impossible identities, and queue exhaustion fail explicitly.

fun offer(packet: RemotePacketAdmission, nowMillis: Long)

Consumes a freshly decoded opaque frame without a second payload copy. RemotePacketAdmission defines one-shot ownership and release; arbitrary public Frame arrays cannot select this route. Admission validation, duplicate handling, gap deadlines and queue accounting match the copying overload.

Link copied to clipboard
fun send(bytes: ByteArray)

Adds a strictly increasing envelope sequence immediately before native delivery. Bootstrap greetings retain the fixed native bound even when peer negotiation has already tightened incoming admission.