mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Some more changes to user disconnect handling.
This commit is contained in:
parent
a3dd6f6956
commit
8ab9abb8e8
3 changed files with 10 additions and 5 deletions
|
@ -1440,7 +1440,7 @@ public class SessionImpl implements Session {
|
|||
@Override
|
||||
public boolean endUserSession(String userSessionId) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to mute userSessionId " + userSessionId + '?', "WARNING",
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to end userSessionId " + userSessionId + '?', "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.endUserSession(sessionId, userSessionId);
|
||||
|
|
|
@ -4,9 +4,9 @@ package mage.server;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public enum DisconnectReason {
|
||||
LostConnection(" has lost connection"),
|
||||
BecameInactive(" has become inactive"),
|
||||
Disconnected(" has left XMage"),
|
||||
CleaningUp(" [cleaning up]"),
|
||||
ConnectingOtherInstance(" reconnected and replaced still active old session"),
|
||||
|
@ -15,11 +15,12 @@ public enum DisconnectReason {
|
|||
Undefined("");
|
||||
|
||||
String message;
|
||||
DisconnectReason(String message){
|
||||
|
||||
DisconnectReason(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getMessage(){
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,8 +174,12 @@ public enum UserManager {
|
|||
calendarRemove.add(Calendar.MINUTE, -8);
|
||||
List<User> toRemove = new ArrayList<>();
|
||||
for (User user : users.values()) {
|
||||
if (user.getUserState() == UserState.Disconnected || user.getUserState() == UserState.Offline
|
||||
if (user.getUserState() != UserState.Offline
|
||||
&& user.isExpired(calendarExp.getTime())) {
|
||||
if (user.getUserState() == UserState.Connected) {
|
||||
user.lostConnection();
|
||||
disconnect(user.getId(), DisconnectReason.BecameInactive);
|
||||
}
|
||||
user.setUserState(UserState.Offline);
|
||||
}
|
||||
if (user.getUserState() == UserState.Offline && user.isExpired(calendarRemove.getTime())) {
|
||||
|
|
Loading…
Reference in a new issue