Shut down Orin: confirmed poweroff, sent once with the hello's boot_id
/ crosscheck (push) Successful in 1s
CI / Analyze & Test (push) Successful in 10s
CI / Debug APK (push) Successful in 16s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
This commit is contained in:
2026-10-13 18:35:49 +09:00
parent db5253587b
commit 88c572f447
2 changed files with 78 additions and 0 deletions
+21
View File
@@ -93,6 +93,27 @@ class Boundary extends ChangeNotifier {
return id;
}
/// Send once, never resent: for commands that must not run twice, like `poweroff`, whose
/// effect wipes svc-gw's ack cache. Null when not connected; nothing is queued then.
String? commandOnce(String cmd, [Map<String, dynamic> args = const {}]) {
if (_ws == null || hello == null) return null;
final id = '${DateTime.now().microsecondsSinceEpoch.toRadixString(36)}-${_rng.nextInt(1 << 32).toRadixString(36)}';
_add(jsonEncode({'t': 'cmd', 'id': id, 'cmd': cmd, 'args': args}));
return id;
}
/// The ack for [id], if it arrives within [within].
Future<Ack?> ackFor(String id, {Duration within = const Duration(seconds: 3)}) async {
final end = DateTime.now().add(within);
while (DateTime.now().isBefore(end)) {
for (final a in acks) {
if (a.id == id) return a;
}
await Future.delayed(const Duration(milliseconds: 100));
}
return null;
}
Future<void> _loop() async {
while (_running) {
_set(LinkState.connecting, 'connecting to $url');