summaryrefslogtreecommitdiff
path: root/discord/discord.hpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-08-19 21:08:57 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-08-19 21:08:57 -0400
commit4b903bbd3e8436e1d63b8c12e76d8a3c924da5fc (patch)
treeaaf25a464d5a308322afd82805bbbcb31ab2f65c /discord/discord.hpp
parent0cd0260f2e4cfe11678cdac4f965c9abf64b3592 (diff)
downloadabaddon-portaudio-4b903bbd3e8436e1d63b8c12e76d8a3c924da5fc.tar.gz
abaddon-portaudio-4b903bbd3e8436e1d63b8c12e76d8a3c924da5fc.zip
add http client and channel reordering (waste of time)
Diffstat (limited to 'discord/discord.hpp')
-rw-r--r--discord/discord.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/discord/discord.hpp b/discord/discord.hpp
index 3c27efe..fa09ce2 100644
--- a/discord/discord.hpp
+++ b/discord/discord.hpp
@@ -1,5 +1,6 @@
#pragma once
#include "websocket.hpp"
+#include "http.hpp"
#include <nlohmann/json.hpp>
#include <thread>
#include <unordered_map>
@@ -21,9 +22,14 @@ struct Snowflake {
return m_num < s.m_num;
}
+ operator uint64_t() const noexcept {
+ return m_num;
+ }
+
const static int Invalid = -1;
friend void from_json(const nlohmann::json &j, Snowflake &s);
+ friend void to_json(nlohmann::json &j, const Snowflake &s);
private:
friend struct std::hash<Snowflake>;
@@ -286,6 +292,8 @@ private:
class Abaddon;
class DiscordClient {
+ friend class Abaddon;
+
public:
static const constexpr char *DiscordGateway = "wss://gateway.discord.gg/?v=6&encoding=json";
static const constexpr char *DiscordAPI = "https://discord.com/api";
@@ -301,6 +309,10 @@ public:
using Guilds_t = std::unordered_map<Snowflake, GuildData>;
const Guilds_t &GetGuilds() const;
const UserSettingsData &GetUserSettings() const;
+ std::vector<std::pair<Snowflake, GuildData>> GetUserSortedGuilds() const;
+ void UpdateSettingsGuildPositions(const std::vector<Snowflake> &pos);
+
+ void UpdateToken(std::string token);
private:
void HandleGatewayMessage(nlohmann::json msg);
@@ -309,6 +321,10 @@ private:
void SendIdentify();
Abaddon *m_abaddon = nullptr;
+ HTTPClient m_http;
+
+ std::string m_token;
+
mutable std::mutex m_mutex;
void StoreGuild(Snowflake id, const GuildData &g);