From 929ebf1a6008d861473e3ceffd11cd4eca90d620 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 15 Nov 2022 02:14:49 -0500 Subject: mess with some websocket stuff to try and fix things to be honest, im not sure what ive done here. whatever memory i have of the issue i was trying to fix has long disappeared by the time im committing this. theres still some issues with being force disconnected and i really dont understand it ill figure it out eventually... maybe :/ --- src/discord/discord.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/discord/discord.cpp') diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index 2a08574..cd16aa8 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -9,7 +9,8 @@ using namespace std::string_literals; DiscordClient::DiscordClient(bool mem_store) : m_decompress_buf(InflateChunkSize) - , m_store(mem_store) { + , m_store(mem_store) + , m_websocket("gateway-ws") { m_msg_dispatch.connect(sigc::mem_fun(*this, &DiscordClient::MessageDispatch)); auto dispatch_cb = [this]() { m_generic_mutex.lock(); @@ -2171,6 +2172,11 @@ void DiscordClient::HandleGatewayVoiceStateUpdate(const GatewayMessage &msg) { if (data.UserID == m_user_data.ID) { spdlog::get("discord")->debug("Voice session ID: {}", data.SessionID); m_voice.SetSessionID(data.SessionID); + + // channel_id = null means disconnect. stop cuz out of order maybe + if (!data.ChannelID.has_value()) { + m_voice.Stop(); + } } else { if (data.GuildID.has_value() && data.Member.has_value()) { if (data.Member->User.has_value()) { @@ -2504,9 +2510,8 @@ void DiscordClient::SetSuperPropertiesFromIdentity(const IdentifyMessage &identi void DiscordClient::HandleSocketOpen() { } -void DiscordClient::HandleSocketClose(uint16_t code) { - printf("got socket close code: %d\n", code); - auto close_code = static_cast(code); +void DiscordClient::HandleSocketClose(const ix::WebSocketCloseInfo &info) { + auto close_code = static_cast(info.code); auto cb = [this, close_code]() { m_heartbeat_waiter.kill(); if (m_heartbeat_thread.joinable()) m_heartbeat_thread.join(); -- cgit v1.2.3