mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08: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 UUID roomId;
|
||||||
private boolean isTournament;
|
private boolean isTournament;
|
||||||
private Session session;
|
private Session session;
|
||||||
private TableWaitModel tableWaitModel;
|
private final TableWaitModel tableWaitModel;
|
||||||
private UpdateSeatsTask updateTask;
|
private UpdateSeatsTask updateTask;
|
||||||
|
|
||||||
/** Creates new form TableWaitingDialog */
|
/** Creates new form TableWaitingDialog */
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.ChatMessage.MessageType;
|
import mage.view.ChatMessage.MessageType;
|
||||||
import mage.view.ChatMessage.SoundToPlay;
|
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) {
|
public void removeUser(UUID userId, User.DisconnectReason reason) {
|
||||||
|
Logger.getLogger(ChatManager.class).debug("Remove user start");
|
||||||
for (ChatSession chat: chatSessions.values()) {
|
for (ChatSession chat: chatSessions.values()) {
|
||||||
chat.kill(userId, reason);
|
chat.kill(userId, reason);
|
||||||
}
|
}
|
||||||
|
Logger.getLogger(ChatManager.class).debug("Remove user end");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ import org.apache.log4j.Logger;
|
||||||
public class ChatSession {
|
public class ChatSession {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ChatSession.class);
|
private static final Logger logger = Logger.getLogger(ChatSession.class);
|
||||||
private ConcurrentHashMap<UUID, String> clients = new ConcurrentHashMap<UUID, String>();
|
private final ConcurrentHashMap<UUID, String> clients = new ConcurrentHashMap<>();
|
||||||
private UUID chatId;
|
private final UUID chatId;
|
||||||
private DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
private final DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
||||||
|
|
||||||
public ChatSession() {
|
public ChatSession() {
|
||||||
chatId = UUID.randomUUID();
|
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)) {
|
if (userId != null && clients.containsKey(userId)) {
|
||||||
|
logger.debug("kill user: Start kill userId " + userId);
|
||||||
String userName = clients.get(userId);
|
String userName = clients.get(userId);
|
||||||
String message;
|
String message;
|
||||||
clients.remove(userId);
|
clients.remove(userId);
|
||||||
|
logger.debug("kill user: After remove " + userId);
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case Disconnected:
|
case Disconnected:
|
||||||
message = " has left MAGE";
|
message = " has left MAGE";
|
||||||
|
|
@ -81,7 +83,7 @@ public class ChatSession {
|
||||||
message = " has left chat";
|
message = " has left chat";
|
||||||
}
|
}
|
||||||
broadcast(null, new StringBuilder(userName).append(message).toString(), MessageColor.BLUE, true, MessageType.STATUS);
|
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 msg = message;
|
||||||
final String time = (withTime ? timeFormatter.format(new Date()):"");
|
final String time = (withTime ? timeFormatter.format(new Date()):"");
|
||||||
final String username = userName;
|
final String username = userName;
|
||||||
logger.debug("Broadcasting '" + msg + "' for " + chatId);
|
logger.trace("Broadcasting '" + msg + "' for " + chatId);
|
||||||
for (UUID userId: clients.keySet()) {
|
for (UUID userId: clients.keySet()) {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|
|
||||||
|
|
@ -237,8 +237,12 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExpired(Date expired) {
|
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());
|
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() {
|
private void reconnect() {
|
||||||
|
|
@ -317,24 +321,21 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill(DisconnectReason reason) {
|
public void kill(DisconnectReason reason) {
|
||||||
logger.debug("kill: kill game sessions");
|
|
||||||
for (GameSession gameSession: gameSessions.values()) {
|
for (GameSession gameSession: gameSessions.values()) {
|
||||||
gameSession.kill();
|
gameSession.kill();
|
||||||
}
|
}
|
||||||
logger.debug("kill: kill draft sessions");
|
|
||||||
for (DraftSession draftSession: draftSessions.values()) {
|
for (DraftSession draftSession: draftSessions.values()) {
|
||||||
draftSession.setKilled();
|
draftSession.setKilled();
|
||||||
}
|
}
|
||||||
logger.debug("kill: kill tournament sessions");
|
|
||||||
for (TournamentSession tournamentSession: tournamentSessions.values()) {
|
for (TournamentSession tournamentSession: tournamentSessions.values()) {
|
||||||
tournamentSession.setKilled();
|
tournamentSession.setKilled();
|
||||||
}
|
}
|
||||||
logger.debug("kill: leave tables");
|
|
||||||
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
for (Entry<UUID, Table> entry: tables.entrySet()) {
|
||||||
TableManager.getInstance().leaveTable(userId, entry.getValue().getId());
|
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);
|
ChatManager.getInstance().removeUser(userId, reason);
|
||||||
|
logger.debug("kill: remove user from chat after");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUserData(UserData userData) {
|
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())
|
logger.info(new StringBuilder(user.getName()).append(" session expired userId: ").append(user.getId())
|
||||||
.append(" sessionId: ").append(user.getSessionId()));
|
.append(" sessionId: ").append(user.getSessionId()));
|
||||||
user.kill(User.DisconnectReason.LostConnection);
|
user.kill(User.DisconnectReason.LostConnection);
|
||||||
|
logger.debug("check Expired: Removing user");
|
||||||
users.remove(user.getId());
|
users.remove(user.getId());
|
||||||
|
logger.debug("check Expired: user removed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue