From f5e78c899a21835dd6673286acd1fa790884ee19 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 11 Jul 2021 01:27:47 -0400 Subject: more reliable menu sensitivty/actions --- discord/discord.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'discord/discord.cpp') diff --git a/discord/discord.cpp b/discord/discord.cpp index 9e620e3..fab2c49 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -24,6 +24,8 @@ DiscordClient::DiscordClient(bool mem_store) } void DiscordClient::Start() { + if (m_client_started) return; + m_http.SetBase(GetAPIURL()); std::memset(&m_zstream, 0, sizeof(m_zstream)); @@ -37,22 +39,22 @@ void DiscordClient::Start() { } void DiscordClient::Stop() { - m_client_started = false; + if (m_client_started) { + inflateEnd(&m_zstream); + m_compressed_buf.clear(); - if (!m_client_connected) return; - - inflateEnd(&m_zstream); - m_compressed_buf.clear(); + m_heartbeat_waiter.kill(); + if (m_heartbeat_thread.joinable()) m_heartbeat_thread.join(); + m_client_connected = false; + m_reconnecting = false; - m_heartbeat_waiter.kill(); - if (m_heartbeat_thread.joinable()) m_heartbeat_thread.join(); - m_client_connected = false; - m_reconnecting = false; + m_store.ClearAll(); + m_guild_to_users.clear(); - m_store.ClearAll(); - m_guild_to_users.clear(); + m_websocket.Stop(); + } - m_websocket.Stop(); + m_client_started = false; } bool DiscordClient::IsStarted() const { -- cgit v1.2.3