Shut down Orin: confirmed poweroff, sent once with the hello's boot_id
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDwfd6Ki8UfG4hK6W5YpJz
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user