optimizations

This commit is contained in:
Loki 2012-05-04 12:40:13 +04:00
parent 9edac9426e
commit 231582f039
2 changed files with 12 additions and 10 deletions

View file

@ -27,11 +27,6 @@
*/
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.game.Table;
import mage.interfaces.callback.ClientCallback;
@ -43,6 +38,12 @@ import mage.server.tournament.TournamentSession;
import mage.view.TableClientMessage;
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
@ -178,7 +179,7 @@ public class User {
}
public boolean isExpired(Date expired) {
return userState == UserState.Disconnected && lastActivity.before(expired);
return /*userState == UserState.Disconnected && */ lastActivity.before(expired);
}
private void reconnect() {

View file

@ -27,6 +27,9 @@
*/
package mage.server;
import mage.view.ChatMessage.MessageColor;
import org.apache.log4j.Logger;
import java.util.Calendar;
import java.util.Collection;
import java.util.UUID;
@ -35,9 +38,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
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
@ -127,9 +127,10 @@ public class UserManager {
private void checkExpired() {
Calendar expired = Calendar.getInstance();
expired.add(Calendar.MINUTE, -10) ;
expired.add(Calendar.MINUTE, -1) ;
for (User user: users.values()) {
if (user.isExpired(expired.getTime())) {
logger.info("user session expired " + user.getId());
user.kill();
users.remove(user.getId());
}