mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
optimizations
This commit is contained in:
parent
9edac9426e
commit
231582f039
2 changed files with 12 additions and 10 deletions
|
@ -27,11 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
@ -43,6 +38,12 @@ import mage.server.tournament.TournamentSession;
|
||||||
import mage.view.TableClientMessage;
|
import mage.view.TableClientMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -178,7 +179,7 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExpired(Date expired) {
|
public boolean isExpired(Date expired) {
|
||||||
return userState == UserState.Disconnected && lastActivity.before(expired);
|
return /*userState == UserState.Disconnected && */ lastActivity.before(expired);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reconnect() {
|
private void reconnect() {
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -35,9 +38,6 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* manages users - if a user is disconnected and 10 minutes have passed with no
|
* manages users - if a user is disconnected and 10 minutes have passed with no
|
||||||
|
@ -127,9 +127,10 @@ public class UserManager {
|
||||||
|
|
||||||
private void checkExpired() {
|
private void checkExpired() {
|
||||||
Calendar expired = Calendar.getInstance();
|
Calendar expired = Calendar.getInstance();
|
||||||
expired.add(Calendar.MINUTE, -10) ;
|
expired.add(Calendar.MINUTE, -1) ;
|
||||||
for (User user: users.values()) {
|
for (User user: users.values()) {
|
||||||
if (user.isExpired(expired.getTime())) {
|
if (user.isExpired(expired.getTime())) {
|
||||||
|
logger.info("user session expired " + user.getId());
|
||||||
user.kill();
|
user.kill();
|
||||||
users.remove(user.getId());
|
users.remove(user.getId());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue