| 883 | } |
| 884 | |
| 885 | bool ControllerAgent::handle_shell(const ShellParam& param) |
| 886 | { |
| 887 | if (!control_unit_) { |
| 888 | LogError << "control_unit_ is nullptr"; |
| 889 | return false; |
| 890 | } |
| 891 | |
| 892 | std::string output; |
| 893 | auto timeout = param.shell_timeout < 0 ? std::chrono::milliseconds::max() : std::chrono::milliseconds(param.shell_timeout); |
| 894 | |
| 895 | auto unit = std::dynamic_pointer_cast<MAA_CTRL_UNIT_NS::ShellableUnit>(control_unit_); |
| 896 | if (!unit) { |
| 897 | LogError << "Shell is not supported for this controller type"; |
| 898 | return false; |
| 899 | } |
| 900 | |
| 901 | bool ret = unit->shell(param.cmd, output, timeout); |
| 902 | |
| 903 | if (ret) { |
| 904 | std::unique_lock lock(shell_output_mutex_); |
| 905 | shell_output_ = std::move(output); |
| 906 | } |
| 907 | |
| 908 | return ret; |
| 909 | } |
| 910 | |
| 911 | bool ControllerAgent::check_stop() |
| 912 | { |