Add message clear option

This commit is contained in:
Janez T
2026-03-05 11:04:41 +01:00
parent 2d9cb0ddb9
commit 234edf5bb0
14 changed files with 1075 additions and 319 deletions

View File

@@ -68,6 +68,12 @@ class ImageProvider with ChangeNotifier {
required Uint8List payload,
})?
sendRawPacketCallback;
Future<bool> Function({
required String sessionId,
required int index,
Duration timeout,
})?
waitForFragmentAckCallback;
ImageProvider() {
_restore();
@@ -229,11 +235,25 @@ class ImageProvider with ChangeNotifier {
continue;
}
try {
final ackFuture = waitForFragmentAckCallback?.call(
sessionId: sessionId,
index: fragment.index,
timeout: const Duration(seconds: 8),
);
await sendRawPacketCallback!(
contactPath: requester.outPath,
contactPathLen: requester.outPathLen,
payload: fragment.encodeBinary(),
);
if (ackFuture != null) {
final acked = await ackFuture;
if (!acked) {
debugPrint(
'⚠️ [ImageProvider] ACK timeout for $sessionId#${fragment.index}',
);
return false;
}
}
} catch (e, st) {
debugPrint('❌ [ImageProvider] Serve error for $sessionId: $e\n$st');
return false;