onSettings method
- UpdateSetting settings
override
Handles an UpdateSetting command and updates the appropriate setting.
Also sends a handshake response to indicate the message was received.
Implementation
@override
Future<void> onSettings(UpdateSetting settings) async {
sendMessage(settings);
if (settings.status == RoverStatus.POWER_OFF) {
logger.critical("Shutting down...");
try {
await collection?.dispose().timeout(const Duration(seconds: 5));
} catch (error) {
logger.critical("Error when shutting down: $error");
}
if (!Platform.isLinux || isTest) return;
await Process.run("sudo", ["shutdown", "now"]);
} else if (settings.status == RoverStatus.RESTART) {
await restart();
}
}