[minor] Some formatting, remove unused code, changes to logging.

This commit is contained in:
LevelX2 2013-05-19 08:29:38 +02:00
parent 7df016ecf8
commit 31da9dcdfd
4 changed files with 10 additions and 13 deletions

View file

@ -44,9 +44,7 @@ public class GameClientMessage implements Serializable {
private CardsView cardsView;
private CardsView cardsView2;
private String message;
private AbilityPickerView abilityView;
private boolean flag;
private boolean cancel;
private String[] strings;
private Set<UUID> targets;
private int min;
@ -109,10 +107,6 @@ public class GameClientMessage implements Serializable {
return message;
}
public AbilityPickerView getAbilityView() {
return abilityView;
}
public boolean isFlag() {
return flag;
}

View file

@ -70,8 +70,9 @@ public class Session {
public void registerUser(String userName) throws MageException {
this.isAdmin = false;
if (userName.equals("Admin"))
if (userName.equals("Admin")) {
throw new MageException("User name already in use");
}
if (userName.length() > ConfigSettings.getInstance().getMaxUserNameLength()) {
throw new MageException(new StringBuilder("User name may not be longer than ").append(ConfigSettings.getInstance().getMaxUserNameLength()).append(" characters").toString());
}
@ -87,8 +88,9 @@ public class Session {
if (user == null) { // user already exists
user = UserManager.getInstance().findUser(userName);
if (user.getHost().equals(host)) {
if (user.getSessionId().isEmpty())
if (user.getSessionId().isEmpty()) {
logger.info("Reconnecting session for " + userName);
}
else {
//throw new MageException("This machine is already connected");
//disconnect previous one
@ -100,8 +102,9 @@ public class Session {
throw new MageException("User name already in use");
}
}
if (!UserManager.getInstance().connectToSession(sessionId, user.getId()))
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
throw new MageException("Error connecting");
}
this.userId = user.getId();
}

View file

@ -102,14 +102,14 @@ public class User {
this.sessionId = sessionId;
if (sessionId.isEmpty()) {
userState = UserState.Disconnected;
logger.info(new StringBuilder("User ").append(userName).append(" disconnected").toString());
logger.info(new StringBuilder("User ").append(userName).append(" disconnected - userId = ").append(userId.toString()).toString());
} else if (userState == UserState.Created) {
userState = UserState.Connected;
logger.info(new StringBuilder("User ").append(userName).append(" created").toString());
logger.info(new StringBuilder("User ").append(userName).append(" created - userId = ").append(userId.toString()).toString());
} else {
userState = UserState.Reconnected;
reconnect();
logger.info(new StringBuilder("User ").append(userName).append(" reconnected").toString());
logger.info(new StringBuilder("User ").append(userName).append(" reconnected - userId = ").append(userId.toString()).toString());
}
}

View file

@ -120,7 +120,7 @@ public class UserManager {
public void removeUser(UUID userId, User.DisconnectReason reason) {
if (users.containsKey(userId)) {
logger.info("user removed" + userId);
logger.info("user removed " + userId);
ChatManager.getInstance().removeUser(userId, reason);
ChatManager.getInstance().broadcast(userId, "has disconnected", MessageColor.BLACK);
users.get(userId).kill(User.DisconnectReason.Disconnected);