Readded message if user lost connection.

This commit is contained in:
LevelX2 2018-01-28 18:03:37 +01:00
parent 66eb1de7f1
commit 34a884546a
2 changed files with 11 additions and 0 deletions

View file

@ -295,6 +295,15 @@ public enum ChatManager {
}
public void sendLostConnectionMessage(UUID userId, DisconnectReason reason) {
UserManager.instance.getUser(userId).ifPresent(user
-> getChatSessions()
.stream()
.filter(chat -> chat.hasUser(userId))
.forEach(chatSession -> chatSession.broadcast(null, user.getName() + reason.getMessage(), MessageColor.BLUE, true, MessageType.STATUS, null)));
}
public void removeUser(UUID userId, DisconnectReason reason) {
for (ChatSession chatSession : getChatSessions()) {
if (chatSession.hasUser(userId)) {

View file

@ -139,6 +139,8 @@ public enum UserManager {
if (reason == DisconnectReason.Disconnected) {
removeUserFromAllTablesAndChat(userId, reason);
user.get().setUserState(UserState.Offline);
} else {
ChatManager.instance.sendLostConnectionMessage(userId, reason);
}
}
}