aboutsummaryrefslogtreecommitdiff
path: root/include/client/web_socket_client.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/client/web_socket_client.hpp')
-rw-r--r--include/client/web_socket_client.hpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/client/web_socket_client.hpp b/include/client/web_socket_client.hpp
index 0f58749..63fa634 100644
--- a/include/client/web_socket_client.hpp
+++ b/include/client/web_socket_client.hpp
@@ -1,7 +1,11 @@
#pragma once
+#include <functional>
#include <string>
+#include <websocketpp/client.hpp>
+#include <websocketpp/config/asio_client.hpp>
+
namespace client
{
/**
@@ -42,6 +46,27 @@ public:
virtual std::tuple<std::string, bool> send(std::string message, std::string uri) = 0;
/**
+ * @brief Sends the given message to the given server and sets up a message handler for
+ * messages received from the server.
+ * @returns A tuple indicating the server URI and whether the message was successfully
+ * sent.
+ * @remark Use this method to send a message and set up a message handler for responses in the
+ * same call.
+ */
+ virtual std::tuple<std::string, bool> send(
+ std::string message,
+ std::string uri,
+ std::function<void(const std::string&)> messageHandler) = 0;
+
+ /**
+ * @brief Sets up a message handler for the given server.
+ * @param uri The URI of the server to which the message handler should be attached.
+ * @param messageHandler A callable object that will be invoked with the payload the client
+ * receives from the server.
+ */
+ virtual void receive(std::string uri, std::function<void(const std::string&)> messageHandler) = 0;
+
+ /**
* @brief Closes the connection to the given server.
*/
virtual void closeConnection(std::string uri) = 0;