aboutsummaryrefslogtreecommitdiff
path: root/source/lib/include/wanda/control/commander.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib/include/wanda/control/commander.hpp')
-rw-r--r--source/lib/include/wanda/control/commander.hpp67
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