mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
added additional logging + keep session alive for most connection errors
This commit is contained in:
parent
0dff1ac743
commit
b9eac322d2
4 changed files with 13 additions and 7 deletions
|
@ -705,11 +705,15 @@ public class Session {
|
|||
}
|
||||
|
||||
private void handleRemoteException(RemoteException ex) {
|
||||
server = null;
|
||||
logger.log(Level.SEVERE, "Connection to server lost", ex);
|
||||
frame.setStatusText("Not connected");
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Connection to server lost.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
frame.disableButtons();
|
||||
logger.log(Level.SEVERE, "Communication error", ex);
|
||||
if (ex instanceof java.rmi.ConnectException) {
|
||||
server = null;
|
||||
frame.setStatusText("Not connected");
|
||||
frame.disableButtons();
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Communication error - disconnecting.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
else
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Communication error.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
private void handleMageException(MageException ex) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue