diff options
Diffstat (limited to 'discord/websocket.hpp')
-rw-r--r-- | discord/websocket.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/discord/websocket.hpp b/discord/websocket.hpp new file mode 100644 index 0000000..47a60d5 --- /dev/null +++ b/discord/websocket.hpp @@ -0,0 +1,22 @@ +#pragma once +#include <ixwebsocket/IXNetSystem.h> +#include <ixwebsocket/IXWebSocket.h> +#include <string> +#include <functional> +#include <nlohmann/json.hpp> + +class Websocket { +public: + Websocket(); + void StartConnection(std::string url); + + using JSONCallback_t = std::function<void(nlohmann::json)>; + void SetJSONCallback(JSONCallback_t func); + void Send(const std::string &str); + +private: + void OnMessage(const ix::WebSocketMessagePtr &msg); + + JSONCallback_t m_json_callback; + ix::WebSocket m_websocket; +}; |