sendOperations method
Sends multiple operations to the server/peers efficiently.
Implementation
@override
Future<void> sendOperations(List<Operation> operations) async {
const transientOps = {'CURSOR_MOVE', 'GHOST_UPDATE', 'PRESENCE_UPDATE'};
final opsToQueue = <Operation>[];
for (final op in operations) {
if (transientOps.contains(op.type)) {
if (_innerClient != null && _isConnected) {
await _innerClient!.sendOperation(op);
} else {
print('OfflineClient: Dropping transient operation ${op.type} because offline');
}
} else {
opsToQueue.add(op);
}
}
if (opsToQueue.isNotEmpty) {
// When connected, send directly to avoid the expensive
// sqlite_crdt queue round-trip (especially slow on web).
if (_innerClient != null && _isConnected) {
print('OfflineClient: Sending ${opsToQueue.length} operations directly (connected)');
await _innerClient!.sendOperations(opsToQueue);
} else {
await _queueOperations(opsToQueue);
_flushQueue();
}
}
}