flush method
Pushes every queued blob, if allowed.
A push is sent only when a welcome was received on the current connection and no other push is in flight (acks pair with pushes one-to-one).
Implementation
Future<void> flush() async {
if (!_handshaken || _queue.hasInFlight || _queue.isEmpty) {
return;
}
final blobs = _queue.takeInFlight();
try {
await client.sendMessage(
RelayPushMessage(
documentId: document.documentId,
changes: blobs,
),
);
} catch (_) {
// The push did not go out: return the window to the pending state so
// the blobs are re-pushed after the reconnect welcome.
_queue.resetInFlight();
}
}