diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-08-17 02:40:03 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-08-17 02:40:03 -0400 |
commit | 18af78e6af49821f8c7adb5b4325d75c8bf4fd03 (patch) | |
tree | 2a2812d604fa0b00891613e868a79972159886aa /discord/websocket.hpp | |
parent | 212511e29d01af9b096e91371956b28de834bd13 (diff) | |
download | abaddon-portaudio-18af78e6af49821f8c7adb5b4325d75c8bf4fd03.tar.gz abaddon-portaudio-18af78e6af49821f8c7adb5b4325d75c8bf4fd03.zip |
connect and heartbeat
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; +}; |