summaryrefslogtreecommitdiff
path: root/discord/discord.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'discord/discord.cpp')
-rw-r--r--discord/discord.cpp26
1 files changed, 14 insertions, 12 deletions
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 {