mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
Some changes to debug logging messages.
This commit is contained in:
parent
7480802f93
commit
236ebe2a12
5 changed files with 21 additions and 13 deletions
|
@ -62,7 +62,7 @@ public class TableWaitingDialog extends MageDialog {
|
|||
private UUID roomId;
|
||||
private boolean isTournament;
|
||||
private Session session;
|
||||
private TableWaitModel tableWaitModel;
|
||||
private final TableWaitModel tableWaitModel;
|
||||
private UpdateSeatsTask updateTask;
|
||||
|
||||
/** Creates new form TableWaitingDialog */
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.ChatMessage.MessageType;
|
||||
import mage.view.ChatMessage.SoundToPlay;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -158,8 +159,10 @@ public class ChatManager {
|
|||
}
|
||||
|
||||
public void removeUser(UUID userId, User.DisconnectReason reason) {
|
||||
Logger.getLogger(ChatManager.class).debug("Remove user start");
|
||||
for (ChatSession chat: chatSessions.values()) {
|
||||
chat.kill(userId, reason);
|
||||
}
|
||||
Logger.getLogger(ChatManager.class).debug("Remove user end");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ import org.apache.log4j.Logger;
|
|||
public class ChatSession {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ChatSession.class);
|
||||
private ConcurrentHashMap<UUID, String> clients = new ConcurrentHashMap<UUID, String>();
|
||||
private UUID chatId;
|
||||
private DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
||||
private final ConcurrentHashMap<UUID, String> clients = new ConcurrentHashMap<>();
|
||||
private final UUID chatId;
|
||||
private final DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
||||
|
||||
public ChatSession() {
|
||||
chatId = UUID.randomUUID();
|
||||
|
@ -65,11 +65,13 @@ public class ChatSession {
|
|||
}
|
||||
}
|
||||
|
||||
public void kill(UUID userId, User.DisconnectReason reason) {
|
||||
synchronized public void kill(UUID userId, User.DisconnectReason reason) {
|
||||
if (userId != null && clients.containsKey(userId)) {
|
||||
logger.debug("kill user: Start kill userId " + userId);
|
||||
String userName = clients.get(userId);
|
||||
String message;
|
||||
clients.remove(userId);
|
||||
logger.debug("kill user: After remove " + userId);
|
||||
switch (reason) {
|
||||
case Disconnected:
|
||||
message = " has left MAGE";
|
||||
|
@ -81,7 +83,7 @@ public class ChatSession {
|
|||
message = " has left chat";
|
||||
}
|
||||
broadcast(null, new StringBuilder(userName).append(message).toString(), MessageColor.BLUE, true, MessageType.STATUS);
|
||||
logger.debug(userName + message + " " + chatId);
|
||||
logger.debug("kill user: " + userName + message + " " + chatId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +125,7 @@ public class ChatSession {
|
|||
final String msg = message;
|
||||
final String time = (withTime ? timeFormatter.format(new Date()):"");
|
||||
final String username = userName;
|
||||
logger.debug("Broadcasting '" + msg + "' for " + chatId);
|
||||
logger.trace("Broadcasting '" + msg + "' for " + chatId);
|
||||
for (UUID userId: clients.keySet()) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
|
|
|
@ -237,8 +237,12 @@ public class User {
|
|||
}
|
||||
|
||||
public boolean isExpired(Date expired) {
|
||||
if (lastActivity.before(expired)) {
|
||||
logger.debug(new StringBuilder(userName).append(" is expired!"));
|
||||
return true;
|
||||
}
|
||||
logger.trace(new StringBuilder("isExpired: User ").append(userName).append(" lastActivity: ").append(lastActivity).append(" expired: ").append(expired).toString());
|
||||
return /*userState == UserState.Disconnected && */ lastActivity.before(expired);
|
||||
return false; /*userState == UserState.Disconnected && */
|
||||
}
|
||||
|
||||
private void reconnect() {
|
||||
|
@ -317,24 +321,21 @@ public class User {
|
|||
}
|
||||
|
||||
public void kill(DisconnectReason reason) {
|
||||
logger.debug("kill: kill game sessions");
|
||||
for (GameSession gameSession: gameSessions.values()) {
|
||||
gameSession.kill();
|
||||
}
|
||||
logger.debug("kill: kill draft sessions");
|
||||
for (DraftSession draftSession: draftSessions.values()) {
|
||||
draftSession.setKilled();
|
||||
}
|
||||
logger.debug("kill: kill tournament sessions");
|
||||
for (TournamentSession tournamentSession: tournamentSessions.values()) {
|
||||
tournamentSession.setKilled();
|
||||
}
|
||||
logger.debug("kill: leave tables");
|
||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||
TableManager.getInstance().leaveTable(userId, entry.getValue().getId());
|
||||
}
|
||||
logger.debug("kill: remove user from chat");
|
||||
logger.debug("kill: remove user from chat before");
|
||||
ChatManager.getInstance().removeUser(userId, reason);
|
||||
logger.debug("kill: remove user from chat after");
|
||||
}
|
||||
|
||||
public void setUserData(UserData userData) {
|
||||
|
|
|
@ -160,7 +160,9 @@ public class UserManager {
|
|||
logger.info(new StringBuilder(user.getName()).append(" session expired userId: ").append(user.getId())
|
||||
.append(" sessionId: ").append(user.getSessionId()));
|
||||
user.kill(User.DisconnectReason.LostConnection);
|
||||
logger.debug("check Expired: Removing user");
|
||||
users.remove(user.getId());
|
||||
logger.debug("check Expired: user removed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue