sendOperation method
Sends an operation to the server/peers.
Implementation
@override
Future<void> sendOperation(Operation operation) async {
// Ephemeral operations should bypass persistence if possible to avoid DB contention.
// They are only useful in real-time.
const transientOps = {'CURSOR_MOVE', 'GHOST_UPDATE', 'PRESENCE_UPDATE'};
if (transientOps.contains(operation.type)) {
if (_innerClient != null && _isConnected) {
// Send directly, skip queue
await _innerClient!.sendOperation(operation);
return;
}
// If offline, we just drop them, as they are real-time only.
print('OfflineClient: Dropping transient operation ${operation.type} because offline');
return;
}
// Outbox pattern: Always queue first to ensure persistence against crashes/network loss
await _queueOperation(operation);
// Then attempt to flush (send to server)
_flushQueue();
}