encodeIndiCommandChunks function Protocol
Encodes command as UTF-8 bytes, split into chunks of at most about
64 KiB so large BLOB uploads can be written to a socket progressively.
Implementation
Iterable<Uint8List> encodeIndiCommandChunks(IndiCommand command) sync* {
final pending = StringBuffer();
for (final piece in _pieces(command)) {
pending.write(piece);
if (pending.length >= _blobPieceBytes) {
yield utf8.encode(pending.toString());
pending.clear();
}
}
if (pending.isNotEmpty) yield utf8.encode(pending.toString());
}