* Fixed a problem that chat messages were no longer broadcast (fixes #3050).

This commit is contained in:
LevelX2 2017-04-02 10:51:00 +02:00
parent 15c1c7f8c0
commit 4c35650b2b

View file

@ -27,6 +27,10 @@
*/ */
package mage.server; package mage.server;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mage.cards.repository.CardInfo; import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.server.exceptions.UserNotFoundException; import mage.server.exceptions.UserNotFoundException;
@ -36,11 +40,6 @@ import mage.view.ChatMessage.MessageType;
import mage.view.ChatMessage.SoundToPlay; import mage.view.ChatMessage.SoundToPlay;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
@ -50,7 +49,6 @@ public enum ChatManager {
private static final Logger logger = Logger.getLogger(ChatManager.class); private static final Logger logger = Logger.getLogger(ChatManager.class);
private static final HashMap<String, String> userMessages = new HashMap<>(); private static final HashMap<String, String> userMessages = new HashMap<>();
private final ConcurrentHashMap<UUID, ChatSession> chatSessions = new ConcurrentHashMap<>(); private final ConcurrentHashMap<UUID, ChatSession> chatSessions = new ConcurrentHashMap<>();
public UUID createChatSession(String info) { public UUID createChatSession(String info) {
@ -159,7 +157,6 @@ public enum ChatManager {
userMessages.put(userName, message); userMessages.put(userName, message);
if (messageType == MessageType.TALK) { if (messageType == MessageType.TALK) {
if (user.getChatLockedUntil() != null) { if (user.getChatLockedUntil() != null) {
if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) { if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) {
@ -173,8 +170,8 @@ public enum ChatManager {
} }
} }
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
} }
chatSession.broadcast(userName, message, color, withTime, messageType, soundToPlay);
} }
} }
@ -255,8 +252,8 @@ public enum ChatManager {
} }
public void sendReconnectMessage(UUID userId) { public void sendReconnectMessage(UUID userId) {
UserManager.instance.getUser(userId).ifPresent(user -> UserManager.instance.getUser(userId).ifPresent(user
chatSessions.values() -> chatSessions.values()
.stream() .stream()
.filter(chat -> chat.hasUser(userId)) .filter(chat -> chat.hasUser(userId))
.forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null))); .forEach(chatSession -> chatSession.broadcast(null, user.getName() + " has reconnected", MessageColor.BLUE, true, MessageType.STATUS, null)));
@ -275,6 +272,4 @@ public enum ChatManager {
return new ArrayList<>(chatSessions.values()); return new ArrayList<>(chatSessions.values());
} }
} }