RpcStreamRouter class

Per-stream delivery for a transport that multiplexes many calls.

A transport exposes every incoming message on one broadcast stream, and getMessagesForStream(id) has to hand each caller only its own. Doing that by filtering the broadcast costs one predicate per active stream per message, and lets a stream-scoped error reach every subscriber; this gives each stream its own controller instead.

Transport-authoring API, like RpcBufferedBroadcastController beside it. It owns ONLY the per-stream half — the transport keeps its own broadcast and decides what to put on it.

What breaks if a transport hand-rolls this instead: the four that did each had to remember that a subscriber may cancel before end-of-stream (leaking a controller per abandoned call), that close must complete the streams a consumer is still awaiting, and that an error for stream 3 must not surface on stream 5. Three invariants, four copies.

Constructors

RpcStreamRouter()

Properties

hashCode → int
The hash code for this object.
no setterinherited
length → int
Live per-stream controllers. Exposed so a transport can report it in health(), where growth that never returns to a baseline is the leak signal.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(RpcTransportMessage message) → void
Delivers message to its stream, closing that stream on end-of-stream.
addError(int streamId, Object error, [StackTrace? stackTrace]) → void
Delivers an error to ONE stream's subscriber.
closeAll({Object? error(int streamId)?}) → void
Closes every remaining stream, reporting error first where it returns one.
contains(int streamId) → bool
Whether streamId currently has a subscriber-facing controller.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(int streamId) → StreamController<RpcTransportMessage>?
Drops streamId's controller without closing it.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](int streamId) → Stream<RpcTransportMessage>
The stream for streamId, creating its controller on first call.