Skip to content

Commit

Permalink
Added CacheClearing fixes and resetting boolean dealing with member c…
Browse files Browse the repository at this point in the history
…hunk loading.
  • Loading branch information
DV8FromTheWorld committed Oct 14, 2016
1 parent 5a02146 commit a3647ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Expand Up @@ -87,4 +87,10 @@ public void modifyExpectedGuildMember(String guildId, int changeAmount)
//Ignore. If one of the above things doesn't exist, causing an NPE, then we don't need to worry.
catch (NullPointerException ignored) {}
}

public void clearCache()
{
expectedGuildMembers.clear();
memberChunksCache.clear();
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/dv8tion/jda/core/handle/ReadyHandler.java
Expand Up @@ -99,6 +99,7 @@ protected String handleInternally(JSONObject content)

public void guildLoadComplete(JSONObject content)
{
api.getClient().setChunkingAndSyncing(false);
EntityBuilder builder = EntityBuilder.get(api);
JSONArray privateChannels = content.getJSONArray("private_channels");

Expand Down Expand Up @@ -194,7 +195,7 @@ private void checkIfReadyToSendRequests()
{
if (acknowledgedGuilds.size() == incompleteGuilds.size())
{
api.getClient().setChunkingAndSyncing();
api.getClient().setChunkingAndSyncing(true);
if (api.getAccountType() == AccountType.CLIENT)
sendGuildSyncRequests();
sendMemberChunkRequests();
Expand Down
Expand Up @@ -436,6 +436,7 @@ protected void sendResume()
protected void invalidate()
{
sessionId = null;
chunkingAndSyncing = false;

// TODO: Reimplement audio handler preservation
// //Preserve the audio handlers through registry invalidation
Expand All @@ -461,9 +462,10 @@ protected void invalidate()
api.getFakeUserMap().clear();
api.getFakePrivateChannelMap().clear();
EntityBuilder.get(api).clearCache();
// new ReadyHandler(api, 0).clearCache();
EventCache.get(api).clear();
GuildLock.get(api).clear();
this.<ReadyHandler>getHandler("READY").clearCache();
this.<GuildMembersChunkHandler>getHandler("GUILD_MEMBERS_CHUNK").clearCache();
}

protected void restoreAudioHandlers()
Expand Down Expand Up @@ -695,11 +697,12 @@ public void handleCallbackError(WebSocket websocket, Throwable cause)
// LOG.log(cause);
}

public void setChunkingAndSyncing()
public void setChunkingAndSyncing(boolean active)
{
chunkingAndSyncing = true;
chunkingAndSyncing = active;
}


public HashMap<String, SocketHandler> getHandlers()
{
return handlers;
Expand Down

0 comments on commit a3647ca

Please sign in to comment.