From 577fc0845718ed8ad5bebf02a277c0579a817f77 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 17 May 2024 17:58:38 +0200 Subject: wanda: restructure source layout --- source/lib/include/wanda/control/commander.hpp | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 source/lib/include/wanda/control/commander.hpp (limited to 'source/lib/include/wanda/control/commander.hpp') 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 +#include + +#include +#include +#include +#include +#include + +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 -- cgit v1.2.3