summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-11-15 15:38:39 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2022-11-15 15:38:39 -0500
commitafaba05293fa723734449777e487ac49e676e741 (patch)
tree0ce89257568b883e1d6f3814dc452195f283317a /src
parent929ebf1a6008d861473e3ceffd11cd4eca90d620 (diff)
downloadabaddon-portaudio-afaba05293fa723734449777e487ac49e676e741.tar.gz
abaddon-portaudio-afaba05293fa723734449777e487ac49e676e741.zip
actually reconstruct websocket on voice connect
Diffstat (limited to 'src')
-rw-r--r--src/discord/voiceclient.cpp42
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();