summaryrefslogtreecommitdiff
path: root/discord/discord.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-10-05 21:37:07 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-10-05 21:37:07 -0400
commit0cdaea97dd035bcbf9d46b8a261b3eeaf4dea69c (patch)
treec340566dbccc77d2d3cb21b1290e01e5c1c0d9c4 /discord/discord.cpp
parentcfcb0d4e662b960dcdd331a7c61dc2b9c614f930 (diff)
downloadabaddon-portaudio-0cdaea97dd035bcbf9d46b8a261b3eeaf4dea69c.tar.gz
abaddon-portaudio-0cdaea97dd035bcbf9d46b8a261b3eeaf4dea69c.zip
slap a bunch of shit everywhere until the crashing stops
Diffstat (limited to 'discord/discord.cpp')
-rw-r--r--discord/discord.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp
index 4d43486..79f2886 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -5,6 +5,9 @@
DiscordClient::DiscordClient()
: m_http(DiscordAPI)
, m_decompress_buf(InflateChunkSize) {
+
+ m_msg_dispatch.connect(sigc::mem_fun(*this, &DiscordClient::MessageDispatch));
+
LoadEventMap();
}
@@ -396,7 +399,10 @@ void DiscordClient::HandleGatewayMessageRaw(std::string str) {
if (err != Z_OK) {
fprintf(stderr, "Error decompressing input buffer %d (%d/%d)\n", err, m_zstream.avail_in, m_zstream.avail_out);
} else {
- HandleGatewayMessage(std::string(m_decompress_buf.begin(), m_decompress_buf.begin() + m_zstream.total_out));
+ m_msg_mutex.lock();
+ m_msg_queue.push(std::string(m_decompress_buf.begin(), m_decompress_buf.begin() + m_zstream.total_out));
+ m_msg_dispatch.emit();
+ m_msg_mutex.unlock();
if (m_decompress_buf.size() > InflateChunkSize)
m_decompress_buf.resize(InflateChunkSize);
}
@@ -407,6 +413,14 @@ void DiscordClient::HandleGatewayMessageRaw(std::string str) {
m_compressed_buf.clear();
}
+void DiscordClient::MessageDispatch() {
+ m_msg_mutex.lock();
+ auto msg = m_msg_queue.front();
+ m_msg_queue.pop();
+ m_msg_mutex.unlock();
+ HandleGatewayMessage(msg);
+}
+
void DiscordClient::HandleGatewayMessage(std::string str) {
GatewayMessage m;
try {