mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Some more chages to logging.
This commit is contained in:
parent
865665767b
commit
ccb554dd87
3 changed files with 30 additions and 8 deletions
|
@ -42,6 +42,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class ChatManager {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ChatManager.class);
|
||||
|
||||
private static final ChatManager INSTANCE = new ChatManager();
|
||||
|
||||
public static ChatManager getInstance() {
|
||||
|
@ -59,19 +61,28 @@ public class ChatManager {
|
|||
}
|
||||
|
||||
public void joinChat(UUID chatId, UUID userId) {
|
||||
chatSessions.get(chatId).join(userId);
|
||||
if (chatSessions.containsKey(chatId)) {
|
||||
chatSessions.get(chatId).join(userId);
|
||||
} else {
|
||||
logger.debug("ChatManager:joinChat - chatId does not exist - chatId: " + chatId +" userId: " + userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void leaveChat(UUID chatId, UUID userId) {
|
||||
if (chatSessions.containsKey(chatId)) {
|
||||
chatSessions.get(chatId).kill(userId, DisconnectReason.CleaningUp);
|
||||
}
|
||||
} else {
|
||||
logger.debug("ChatManager:leaveChat - chatId does not exist - chatId: " + chatId +" userId: " + userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyChatSession(UUID chatId) {
|
||||
if (chatId != null) {
|
||||
if (chatId != null && chatSessions.containsKey(chatId)) {
|
||||
chatSessions.remove(chatId);
|
||||
}
|
||||
} else {
|
||||
logger.debug("ChatManager:destroy chat - chatId does not exist - chatId: " + chatId);
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcast(UUID chatId, String userName, String message, MessageColor color) {
|
||||
|
|
|
@ -1004,6 +1004,9 @@ public class MageServerImpl implements MageServer {
|
|||
protected void execute(final String actionName, final String sessionId, final Action action) throws MageException {
|
||||
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
||||
try {
|
||||
if (actionName.equals("joinChat")) {
|
||||
logger.debug("MageServerImpl.execute sessionId: " + sessionId + " action: " + actionName);
|
||||
}
|
||||
callExecutor.execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
|
@ -1021,7 +1024,7 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -192,8 +191,17 @@ public class Session {
|
|||
return sessionId;
|
||||
}
|
||||
|
||||
public void userLostConnection() {
|
||||
//synchronized public void userLostConnection() {
|
||||
public void userLostConnection() {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user == null) {
|
||||
logger.error("Session.userLostConnection user for session not found sessionId: " + sessionId + " userId: " +userId);
|
||||
return;
|
||||
}
|
||||
if (user.getSessionId().isEmpty()) {
|
||||
logger.debug("Session.userLostConnection user was already disconnected sessionId: " + sessionId + " userId: " +userId);
|
||||
return;
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
StringBuilder sb = new StringBuilder("user ");
|
||||
if (user == null) {
|
||||
|
@ -218,7 +226,7 @@ public class Session {
|
|||
call.setMessageId(messageId++);
|
||||
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||
} catch (HandleCallbackException ex) {
|
||||
logger.fatal(new StringBuilder("Session of userId ").append(userId).append(" fireCallback error: ").append(ex.getMessage()).toString(), ex);
|
||||
logger.info(new StringBuilder("Session of userId ").append(userId).append(" callback exception: ").append(ex.getMessage()).toString());
|
||||
userLostConnection();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue