mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Readded message if user lost connection.
This commit is contained in:
parent
66eb1de7f1
commit
34a884546a
2 changed files with 11 additions and 0 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue