outgoingCapsule property
Uint8List
get
outgoingCapsule
Implementation
Uint8List get outgoingCapsule {
Uint8List occ = Uint8List(0);
List<int> xxwants = [];
//asks for missing stuff with a snapshot of my stuff
List<ModeratorCapsuleItem> _mcl = [];
int keepBel64kb = 0;
for (ModeratorEntry ee in data.all) {
if (_latelySeenp4p.contains(ee.keyHint)) continue;
if (ee.flags.attachements) {
if (!_xxCache.isXXstored(ee.attachmentLinkAsXXint)) {
xxwants.add(ee.attachmentLinkAsXXint);
}
//capsules explode with too many entries
if (keepBel64kb > 63980) break;
_mcl.add(ModeratorCapsuleItem(
ee.flags.binary,
0,
ee.bl,
ee.pp,
ee.timeElapsedSincePostMs,
ee.body.length,
ee.bodyBytes,
ee.shortLinkBytes.lengthInBytes,
ee.shortLinkBytes,
ee.keyHint,
ee.avatar,
ee.nick,
ee.attachmentLink,
0,
ee.perceivedTimestamp,
ee.likes,
ee.shares,
ee.views,
ee.replycount));
keepBel64kb += _mcl.last.binary.lengthInBytes;
}
}
Uint8List _l = Uint8List(128);
var b0 = new ByteData.view(_l.buffer);
xxwants.shuffle();
int w = 0;
for (var id in xxwants) {
if (_latelySeenp4p.contains(id)) continue;
if (w == _l.lengthInBytes) break;
b0.setUint64(w, id);
w += 8;
}
Uint8List enl = Uint8List(66000);
var wi = 0;
for (var element in _mcl) {
if (wi > 64000) {
break;
}
for (var ib in element.binary) {
enl[wi++] = ib;
}
}
final ModeratorCapsule cap = ModeratorCapsule(Uint8List(0),
enl.sublist(0, wi), Uint8List(0), _l.sublist(0, w), Uint8List(0));
final zut = cap.binary;
final md = ModeratorCapsule.fromBinary(zut);
return zut;
}