WsChannel class

Single persistent WebSocket for all CRUD + bulk + sync events.

Uses OP_PIPELINE with microtask coalescing and adaptive congestion window. Ops in the same microtask are batched into one pipeline frame. The cwnd (AIMD + BBR RTT tracking) limits in-flight batches to prevent server overload.

Constructors

WsChannel({required Uri wsUri, String? jwt, int maxBatchSize = 256, int cwndMax = 6})

Properties

connectionState → Stream<bool>
no setter
cwndMax → int
final
hashCode → int
The hash code for this object.
no setterinherited
isConnected → bool
no setter
maxBatchSize → int
final
onReconnected ↔ void Function()?
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
syncEvents → Stream<SyncEvent>
no setter

Methods

bulkDelete(List<String> keys) → Future<void>
Deletes multiple keys in a single binary frame.
bulkGet(List<String> keys) → Future<Map<String, Uint8List?>>
Retrieves multiple values in a single binary frame.
bulkPut(List<MapEntry<String, Uint8List>> entries) → Future<List<int>>
Uploads multiple key-value pairs in a single binary frame (optimizes I/O).
connect() → Future<void>
delete(String key) → Future<void>
Deletes a value by key.
dispose() → void
emitLocalSync(SyncEvent event) → void
get(String key) → Future<Uint8List?>
Retrieves a value by key. Returns null if not found.
getSchema() → Future<String>
Gets the server index schema via WSS (opcode 29)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String key, Uint8List data) → Future<bool>
Creates or updates a value. Returns true if created.
putRangeTagged(String key, Uint8List data, List<int> tagHashes, List<({int fieldHash, int tagHash, Uint8List valueBytes})> rangeEntries) → Future<bool>
PUT with equality tags + range index entries.
query(String collection, List<int> tagHashes, {int limit = 0}) → Future<Map<String, Uint8List>>
Query: returns IDs + data for docs matching ALL tags.
queryRange(String collection, int fieldHash, Uint8List min, Uint8List max, List<int> andTags, {int limit = 0}) → Future<Map<String, Uint8List>>
Range query: returns docs where field is in min, max.
registerIndex(String collection, String field, String type) → Future<void>
Register a single index field via OP_REGISTER_INDEX (atomic server-side merge).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

encodeOrderable(Object value) → Uint8List
Encode value to orderable bytes for range index.
rangeFieldHash(String field) → int
Field name hash, used as BTreeMap key for range index.
tagHash(String field, String value) → int
Computes the wyhash of a field+value pair (identical to server).