From 64922e213ac731279cf3341253e67509adb2dfc8 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 16 Sep 2022 21:36:12 +0200 Subject: wanda: restructure source directory --- source/include/wanda/commander.hpp | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 source/include/wanda/commander.hpp (limited to 'source/include/wanda/commander.hpp') diff --git a/source/include/wanda/commander.hpp b/source/include/wanda/commander.hpp new file mode 100644 index 0000000..1c76c6d --- /dev/null +++ b/source/include/wanda/commander.hpp @@ -0,0 +1,66 @@ +#ifndef WANDA_COMMANDER_HPP +#define WANDA_COMMANDER_HPP + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace wanda +{ + /** + * @brief The remote control client + * + */ + struct commander : wanda::control_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(asio::io_service & 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(command command); + + void on_error(control_connection::pointer connection, std::error_code error) override; + void on_received(control_connection::pointer connection, message message) override; + + private: + asio::io_service & 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 +#endif \ No newline at end of file -- cgit v1.2.3