diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-01-03 19:01:33 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-01-03 19:01:33 -0500 |
commit | 4740965f4c1ee879a733b4068f4026a0dfa626fd (patch) | |
tree | bf3f3e4cbac1e63fe9ef4f5191e553e8ce615fd7 /src/discord/websocket.cpp | |
parent | 6ff2563e36eac4f90ba241df3937980abd73c579 (diff) | |
download | abaddon-portaudio-4740965f4c1ee879a733b4068f4026a0dfa626fd.tar.gz abaddon-portaudio-4740965f4c1ee879a733b4068f4026a0dfa626fd.zip |
rewrite DiscordVoiceClient and stuff
Diffstat (limited to 'src/discord/websocket.cpp')
-rw-r--r-- | src/discord/websocket.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/discord/websocket.cpp b/src/discord/websocket.cpp index 349913a..d40d057 100644 --- a/src/discord/websocket.cpp +++ b/src/discord/websocket.cpp @@ -20,11 +20,14 @@ Websocket::Websocket(const std::string &id) void Websocket::StartConnection(const std::string &url) { m_log->debug("Starting connection to {}", url); - m_websocket.disableAutomaticReconnection(); - m_websocket.setUrl(url); - m_websocket.setOnMessageCallback([this](auto &&msg) { OnMessage(std::forward<decltype(msg)>(msg)); }); - m_websocket.setExtraHeaders(ix::WebSocketHttpHeaders { { "User-Agent", m_agent } }); // idk if this actually works - m_websocket.start(); + + m_websocket = std::make_unique<ix::WebSocket>(); + + m_websocket->disableAutomaticReconnection(); + m_websocket->setUrl(url); + m_websocket->setOnMessageCallback([this](auto &&msg) { OnMessage(std::forward<decltype(msg)>(msg)); }); + m_websocket->setExtraHeaders(ix::WebSocketHttpHeaders { { "User-Agent", m_agent } }); // idk if this actually works + m_websocket->start(); } void Websocket::SetUserAgent(std::string agent) { @@ -46,13 +49,13 @@ void Websocket::Stop() { void Websocket::Stop(uint16_t code) { m_log->debug("Stopping with close code {}", code); - m_websocket.stop(code); + m_websocket-> stop(code); } void Websocket::Send(const std::string &str) { if (m_print_messages) m_log->trace("Send: {}", str); - m_websocket.sendText(str); + m_websocket->sendText(str); } void Websocket::Send(const nlohmann::json &j) { |