added additional logging + keep session alive for most connection errors

This commit is contained in:
BetaSteward 2011-05-10 23:57:47 -04:00
parent 0dff1ac743
commit b9eac322d2
4 changed files with 13 additions and 7 deletions

View file

@ -74,6 +74,7 @@ public class ChatSession {
public void broadcast(String userName, String message, MessageColor color) {
Calendar cal = new GregorianCalendar();
final String msg = timeFormatter.format(cal.getTime()) + " " + userName + ":" + message;
logger.debug("Broadcasting '" + msg + "' for " + chatId);
for (UUID sessionId: clients.keySet()) {
Session session = SessionManager.getInstance().getSession(sessionId);
if (session != null)

View file

@ -113,7 +113,7 @@ public class ServerImpl extends RemoteServer implements Server {
if (version.compareTo(Main.getVersion()) != 0)
throw new MageException("Wrong client version " + version + ", expecting version " + Main.getVersion());
sessionId = SessionManager.getInstance().createSession(userName, clientId);
logger.info("Session " + sessionId + " created for user " + userName + " at " + getClientHost());
logger.info("User " + userName + " connected from " + getClientHost());
} catch (Exception ex) {
handleException(ex);
}

View file

@ -56,7 +56,7 @@ public class SessionManager {
for (Session session: sessions.values()) {
if (session.getUsername().equals(userName)) {
if (session.getClientId().equals(clientId)) {
logger.info("reconnecting session for " + userName);
logger.info("Reconnecting session " + session.getId() + " for " + userName);
return session.getId();
}
else {
@ -66,6 +66,7 @@ public class SessionManager {
}
Session session = new Session(userName, clientId);
sessions.put(session.getId(), session);
logger.info("Session " + session.getId() + " created for user " + userName);
return session.getId();
}