RpcStreamIdManager constructor
Creates an ID manager for a given role.
isClient True to generate client (odd) IDs; false for server (even).
customMaxId Optional custom upper bound (tests, specialized transports).
resumeAfter Continue an existing sequence instead of starting over —
pass a previous manager's lastIssuedId. Values below the natural start
are ignored, so resumeAfter: -1 and resumeAfter: null behave alike.
Parity is aligned exactly as resumeAfter does it: a cursor of the
wrong parity for this role is rounded UP, so a client keeps issuing odd
ids whatever it is handed. Taken raw, resumeAfter: 4 made a CLIENT
issue 6, 8, 10 — the server's half of the id space.
Implementation
RpcStreamIdManager({
required this.isClient,
int? customMaxId,
int? resumeAfter,
}) : _lastId = _alignedStart(isClient: isClient, resumeAfter: resumeAfter),
_lastIssued = _alignedStart(
isClient: isClient,
resumeAfter: resumeAfter,
),
_firstAssignableId = isClient ? 1 : 2,
_maxAssignableId = _computeMaxAssignableId(
isClient: isClient,
maxIdOverride: customMaxId,
);