summaryrefslogtreecommitdiff
path: root/discord/discord.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'discord/discord.hpp')
-rw-r--r--discord/discord.hpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/discord/discord.hpp b/discord/discord.hpp
index ab390dc..3a98b40 100644
--- a/discord/discord.hpp
+++ b/discord/discord.hpp
@@ -4,8 +4,12 @@
#include <nlohmann/json.hpp>
#include <thread>
#include <unordered_map>
+#include <set>
#include <unordered_set>
#include <mutex>
+#ifdef ABADDON_USE_COMPRESSED_SOCKET
+ #include <zlib.h>
+#endif
// bruh
#ifdef GetMessage
@@ -372,7 +376,11 @@ class DiscordClient {
friend class Abaddon;
public:
+#ifdef ABADDON_USE_COMPRESSED_SOCKET
+ static const constexpr char *DiscordGateway = "wss://gateway.discord.gg/?v=6&encoding=json&compress=zlib-stream";
+#else
static const constexpr char *DiscordGateway = "wss://gateway.discord.gg/?v=6&encoding=json";
+#endif
static const constexpr char *DiscordAPI = "https://discord.com/api";
static const constexpr char *GatewayIdentity = "Discord";
@@ -400,7 +408,14 @@ public:
void UpdateToken(std::string token);
private:
- void HandleGatewayMessage(nlohmann::json msg);
+#ifdef ABADDON_USE_COMPRESSED_SOCKET
+ static const constexpr int InflateChunkSize = 0x10000;
+ std::vector<uint8_t> m_compressed_buf;
+ std::vector<uint8_t> m_decompress_buf;
+#endif
+ std::string DecompressGatewayMessage(std::string str);
+ void HandleGatewayMessageRaw(std::string str);
+ void HandleGatewayMessage(std::string str);
void HandleGatewayReady(const GatewayMessage &msg);
void HandleGatewayMessageCreate(const GatewayMessage &msg);
void HeartbeatThread();