Skip to content

Commit

Permalink
Properly clear channels and channel users on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Dec 31, 2023
1 parent a2fae9a commit c46d11a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/faforever/client/chat/ChatChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import lombok.Getter;
import lombok.ToString;

import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

Expand Down Expand Up @@ -117,7 +118,7 @@ public ChatChannelUser createUserIfNecessary(String username, Consumer<ChatChann
}

public void clearUsers() {
usernameToChatUser.clear();
List.copyOf(usernameToChatUser.keySet()).forEach(this::removeUser);
}

public ObservableList<ChatChannelUser> getTypingUsers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ private void onMessage(String message) {
private void onDisconnect(ClientConnectionEndedEvent event) {
client.getEventManager().unregisterEventListener(this);
channels.values().forEach(ChatChannel::clearUsers);
channels.clear();
List.copyOf(channels.keySet()).forEach(this::removeChannel);
connectionState.set(ConnectionState.DISCONNECTED);
client.shutdown();
}
Expand Down

0 comments on commit c46d11a

Please sign in to comment.