* Added try catch block for user expired handling.

This commit is contained in:
LevelX2 2014-07-08 02:13:26 +02:00
parent b6bc7c6a51
commit 0120808ef8
2 changed files with 37 additions and 29 deletions

View file

@ -66,9 +66,10 @@ public class ChatSession {
} }
synchronized public void kill(UUID userId, DisconnectReason reason) { synchronized public void kill(UUID userId, DisconnectReason reason) {
try {
if (userId != null && clients.containsKey(userId)) { if (userId != null && clients.containsKey(userId)) {
String userName = clients.get(userId); String userName = clients.get(userId);
logger.debug(userName + " leaves chat: " + chatId); logger.debug((userName == null ? "[null]" :userName) + " leaves chat: " + (chatId == null?"[null]":chatId));
clients.remove(userId); clients.remove(userId);
String message = null; String message = null;
switch (reason) { switch (reason) {
@ -86,6 +87,9 @@ public class ChatSession {
logger.debug(userName + " left chat with reason: " + message + " " + chatId); logger.debug(userName + " left chat with reason: " + message + " " + chatId);
} }
} }
} catch(Exception ex) {
logger.fatal(ex);
}
} }
public boolean broadcastInfoToUser(User toUser, String message) { public boolean broadcastInfoToUser(User toUser, String message) {

View file

@ -155,6 +155,7 @@ public class UserManager {
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
try {
logger.debug("checkExpired - start"); logger.debug("checkExpired - start");
Calendar expired = Calendar.getInstance(); Calendar expired = Calendar.getInstance();
expired.add(Calendar.MINUTE, -3); expired.add(Calendar.MINUTE, -3);
@ -168,6 +169,9 @@ public class UserManager {
} }
} }
logger.debug("checkExpired - end"); logger.debug("checkExpired - end");
} catch (Exception ex) {
handleException(ex);
}
} }
} }
); );