mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Server: ignore connection problem logs if user don't have game sessions;
This commit is contained in:
parent
d08e54f6fc
commit
cdce5c2c82
2 changed files with 18 additions and 7 deletions
|
@ -20,6 +20,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -320,13 +321,24 @@ public enum ChatManager {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user -> sendMessageToUserChats(userId, user.getName() + " " + reason.getMessage()));
|
UserManager.instance.getUser(userId).ifPresent(user -> sendMessageToUserChats(userId, user.getName() + " " + reason.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send message to all active waiting/tourney/game chats (but not in main lobby)
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
public void sendMessageToUserChats(UUID userId, String message) {
|
public void sendMessageToUserChats(UUID userId, String message) {
|
||||||
UserManager.instance.getUser(userId).ifPresent(user
|
UserManager.instance.getUser(userId).ifPresent(user -> {
|
||||||
-> getChatSessions()
|
List<ChatSession> chatSessions = getChatSessions().stream()
|
||||||
.stream()
|
|
||||||
.filter(chat -> !chat.getChatId().equals(GamesRoomManager.instance.getMainChatId())) // ignore main lobby
|
.filter(chat -> !chat.getChatId().equals(GamesRoomManager.instance.getMainChatId())) // ignore main lobby
|
||||||
.filter(chat -> chat.hasUser(userId))
|
.filter(chat -> chat.hasUser(userId))
|
||||||
.forEach(chatSession -> chatSession.broadcast(null, message, MessageColor.BLUE, true, MessageType.STATUS, null)));
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (chatSessions.size() > 0) {
|
||||||
|
logger.info("INFORM OPPONENTS by " + user.getName() + ": " + message);
|
||||||
|
chatSessions.forEach(chatSession -> chatSession.broadcast(null, message, MessageColor.BLUE, true, MessageType.STATUS, null));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUser(UUID userId, DisconnectReason reason) {
|
public void removeUser(UUID userId, DisconnectReason reason) {
|
||||||
|
|
|
@ -152,7 +152,6 @@ public enum UserManager {
|
||||||
-> USER_EXECUTOR.execute(
|
-> USER_EXECUTOR.execute(
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
logger.info("INFORM OPPONENTS by " + user.getName() + ": " + message);
|
|
||||||
ChatManager.instance.sendMessageToUserChats(user.getId(), message);
|
ChatManager.instance.sendMessageToUserChats(user.getId(), message);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
|
Loading…
Reference in a new issue