mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
put disconnect reason message in enum
This commit is contained in:
parent
ff6d1541c3
commit
c461d67d34
2 changed files with 19 additions and 31 deletions
|
@ -85,30 +85,9 @@ public class ChatSession {
|
|||
clients.remove(userId);
|
||||
logger.debug(userName + '(' + reason.toString() + ')' + " removed from chatId " + chatId);
|
||||
}
|
||||
String message;
|
||||
switch (reason) {
|
||||
case Disconnected:
|
||||
message = " has left XMage";
|
||||
break;
|
||||
case LostConnection:
|
||||
message = " has lost connection";
|
||||
break;
|
||||
case SessionExpired:
|
||||
message = " session expired";
|
||||
break;
|
||||
case AdminDisconnect:
|
||||
message = " was disconnected by the Admin";
|
||||
break;
|
||||
case ConnectingOtherInstance:
|
||||
message = " reconnected and replaced still active old session";
|
||||
break;
|
||||
case CleaningUp:
|
||||
message = null;
|
||||
break;
|
||||
default:
|
||||
message = " left (" + reason.toString() + ')';
|
||||
}
|
||||
if (message != null) {
|
||||
String message = reason.getMessage();
|
||||
|
||||
if (!message.isEmpty()) {
|
||||
broadcast(null, userName + message, MessageColor.BLUE, true, MessageType.STATUS, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,20 @@ package mage.server;
|
|||
*/
|
||||
|
||||
public enum DisconnectReason {
|
||||
LostConnection,
|
||||
Disconnected,
|
||||
CleaningUp,
|
||||
ConnectingOtherInstance,
|
||||
AdminDisconnect,
|
||||
SessionExpired,
|
||||
Undefined
|
||||
LostConnection(" has lost connection"),
|
||||
Disconnected(" has left XMage"),
|
||||
CleaningUp(" [cleaning up]"),
|
||||
ConnectingOtherInstance(" reconnected and replaced still active old session"),
|
||||
AdminDisconnect(" was disconnected by the Admin"),
|
||||
SessionExpired(" session expired"),
|
||||
Undefined("");
|
||||
|
||||
String message;
|
||||
DisconnectReason(String message){
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage(){
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue