Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/dpp/discordclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ class DPP_EXPORT voiceconn {
* @return reference to self
*/
voiceconn& disconnect();

/**
* @brief Reassigns the owner to the given discord_client.
*/
void reassign_owner(class discord_client* o);
};

/** @brief Implements a discord client. Each discord_client connects to one shard and derives from a websocket client. */
Expand Down
8 changes: 8 additions & 0 deletions src/dpp/discordclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <thread>
#include <dpp/json.h>
#include <dpp/etf.h>
#include <utility>

#define PATH_UNCOMPRESSED_JSON "/?v=" DISCORD_API_VERSION "&encoding=json"
#define PATH_COMPRESSED_JSON "/?v=" DISCORD_API_VERSION "&encoding=json&compress=zlib-stream"
Expand Down Expand Up @@ -72,8 +73,12 @@ discord_client::discord_client(discord_client &old, uint64_t sequence, const std
ready(false),
last_heartbeat_ack(time(nullptr)),
protocol(old.protocol),
connecting_voice_channels(std::move(old.connecting_voice_channels)),
resume_gateway_url(old.resume_gateway_url)
{
for (auto& [shard_id, vconn] : connecting_voice_channels) {
vconn->reassign_owner(this);
}
start_connecting();
}

Expand Down Expand Up @@ -615,5 +620,8 @@ voiceconn& voiceconn::connect(snowflake guild_id) {
return *this;
}

void voiceconn::reassign_owner(discord_client* o) {
creator = o;
}

}
Loading