diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-11-15 15:38:39 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-11-15 15:38:39 -0500 |
commit | afaba05293fa723734449777e487ac49e676e741 (patch) | |
tree | 0ce89257568b883e1d6f3814dc452195f283317a /src | |
parent | 929ebf1a6008d861473e3ceffd11cd4eca90d620 (diff) | |
download | abaddon-portaudio-afaba05293fa723734449777e487ac49e676e741.tar.gz abaddon-portaudio-afaba05293fa723734449777e487ac49e676e741.zip |
actually reconstruct websocket on voice connect
Diffstat (limited to 'src')
-rw-r--r-- | src/discord/voiceclient.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/discord/voiceclient.cpp b/src/discord/voiceclient.cpp index 3118cec..765c2af 100644 --- a/src/discord/voiceclient.cpp +++ b/src/discord/voiceclient.cpp @@ -130,27 +130,6 @@ DiscordVoiceClient::DiscordVoiceClient() { spdlog::get("voice")->critical("sodium_init() failed"); } - m_ws = std::make_unique<Websocket>("voice-ws"); - - m_ws->signal_open().connect([this]() { - spdlog::get("voice")->info("Websocket open"); - SetState(State::Opened); - }); - - m_ws->signal_close().connect([this](const ix::WebSocketCloseInfo &info) { - if (info.remote) { - SetState(State::ClosingByServer); - } - Stop(); - }); - - m_ws->signal_message().connect([this](const std::string &str) { - spdlog::get("voice-ws")->trace("Recv: {}", str); - std::lock_guard<std::mutex> _(m_dispatch_mutex); - m_message_queue.push(str); - m_dispatcher.emit(); - }); - m_udp.signal_data().connect([this](const std::vector<uint8_t> &data) { OnUDPData(data); }); @@ -183,6 +162,27 @@ DiscordVoiceClient::~DiscordVoiceClient() { } void DiscordVoiceClient::Start() { + m_ws = std::make_unique<Websocket>("voice-ws"); + + m_ws->signal_open().connect([this]() { + spdlog::get("voice")->info("Websocket open"); + SetState(State::Opened); + }); + + m_ws->signal_close().connect([this](const ix::WebSocketCloseInfo &info) { + if (info.remote) { + SetState(State::ClosingByServer); + } + Stop(); + }); + + m_ws->signal_message().connect([this](const std::string &str) { + spdlog::get("voice-ws")->trace("Recv: {}", str); + std::lock_guard<std::mutex> _(m_dispatch_mutex); + m_message_queue.push(str); + m_dispatcher.emit(); + }); + SetState(State::Opening); m_ws->StartConnection("wss://" + m_endpoint + "/?v=7"); m_heartbeat_waiter.revive(); |