diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2024-05-17 17:58:38 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2024-05-17 17:58:38 +0200 |
| commit | 577fc0845718ed8ad5bebf02a277c0579a817f77 (patch) | |
| tree | 3d1cdc53c426a0ba60a7996619a7b787850bb3b3 /source/lib/include/wanda/control/commander.hpp | |
| parent | de5bf7ca3b7a2bf6be35b86486b00dc6a071b950 (diff) | |
| download | wanda-develop.tar.xz wanda-develop.zip | |
Diffstat (limited to 'source/lib/include/wanda/control/commander.hpp')
| -rw-r--r-- | source/lib/include/wanda/control/commander.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source/lib/include/wanda/control/commander.hpp b/source/lib/include/wanda/control/commander.hpp new file mode 100644 index 0000000..d7ca73d --- /dev/null +++ b/source/lib/include/wanda/control/commander.hpp @@ -0,0 +1,67 @@ +#ifndef WANDA_CONTROL_COMMANDER_HPP +#define WANDA_CONTROL_COMMANDER_HPP + +#include "wanda/control/connection.hpp" +#include "wanda/proto/command.hpp" +#include "wanda/proto/message.hpp" + +#include <boost/asio/io_context.hpp> +#include <boost/asio/io_service.hpp> + +#include <filesystem> +#include <memory> +#include <optional> +#include <string> +#include <vector> + +namespace wanda::control +{ + /** + * @brief The remote control client + * + */ + struct commander : connection::listener + { + /** + * @brief The interface to be implemented by remote control listeners + */ + struct listener + { + virtual void on_connected(commander & commander){}; + virtual void on_response(commander & commander, std::string response){}; + virtual void on_error(commander & commander, std::string error){}; + }; + + /** + * @brief Construct a new commander + */ + commander(boost::asio::io_context & service, std::filesystem::path socket, listener & listener); + + /** + * @brief Start communication with the remote daemon endpoint + */ + void start(); + + /** + * @brief Stop communication with the remote daemon endpoint + */ + void stop(); + + /** + * @brief Send a command to the remote daemon endpoint + */ + void send(proto::command command); + + void on_error(connection::pointer connection, std::error_code error) override; + void on_received(connection::pointer connection, proto::message message) override; + + private: + boost::asio::io_context & m_service; + wanda::control::connection::protocol::endpoint m_endpoint; + wanda::control::connection::protocol::socket m_socket; + wanda::control::connection::pointer m_connection; + listener & m_listener; + }; + +} // namespace wanda::control +#endif
\ No newline at end of file |
