diff --git a/Mage.Client/config/config.xml b/Mage.Client/config/config.xml
index f545396985..cc832e984a 100644
--- a/Mage.Client/config/config.xml
+++ b/Mage.Client/config/config.xml
@@ -1,28 +1,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml
index 93518e8ba6..f18f3d0ab6 100644
--- a/Mage.Client/pom.xml
+++ b/Mage.Client/pom.xml
@@ -155,7 +155,7 @@
-
+
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
-
- org.jvnet.jaxb2.maven2
-
-
- maven-jaxb2-plugin
-
-
- [0.7.4,)
-
-
- generate
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+
+ org.jvnet.jaxb2.maven2
+
+
+ maven-jaxb2-plugin
+
+
+ [0.7.4,)
+
+
+ generate
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Mage.Server/release/config/config.xml b/Mage.Server/release/config/config.xml
index f6e5f68792..b6bb903412 100644
--- a/Mage.Server/release/config/config.xml
+++ b/Mage.Server/release/config/config.xml
@@ -1,27 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Mage.Server/src/main/java/mage/server/ChatManager.java b/Mage.Server/src/main/java/mage/server/ChatManager.java
index 62586ecfcf..b29589879d 100644
--- a/Mage.Server/src/main/java/mage/server/ChatManager.java
+++ b/Mage.Server/src/main/java/mage/server/ChatManager.java
@@ -39,59 +39,59 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ChatManager {
- private final static ChatManager INSTANCE = new ChatManager();
+ private final static ChatManager INSTANCE = new ChatManager();
- public static ChatManager getInstance() {
- return INSTANCE;
- }
+ public static ChatManager getInstance() {
+ return INSTANCE;
+ }
- private ChatManager() {}
+ private ChatManager() {}
- private ConcurrentHashMap chatSessions = new ConcurrentHashMap();
+ private ConcurrentHashMap chatSessions = new ConcurrentHashMap();
- public UUID createChatSession() {
- ChatSession chatSession = new ChatSession();
- chatSessions.put(chatSession.getChatId(), chatSession);
- return chatSession.getChatId();
- }
+ public UUID createChatSession() {
+ ChatSession chatSession = new ChatSession();
+ chatSessions.put(chatSession.getChatId(), chatSession);
+ return chatSession.getChatId();
+ }
- public void joinChat(UUID chatId, UUID userId) {
- chatSessions.get(chatId).join(userId);
- }
+ public void joinChat(UUID chatId, UUID userId) {
+ chatSessions.get(chatId).join(userId);
+ }
- public void leaveChat(UUID chatId, UUID userId) {
- chatSessions.get(chatId).kill(userId);
- }
+ public void leaveChat(UUID chatId, UUID userId) {
+ chatSessions.get(chatId).kill(userId);
+ }
- public void destroyChatSession(UUID chatId) {
- chatSessions.remove(chatId);
- }
+ public void destroyChatSession(UUID chatId) {
+ chatSessions.remove(chatId);
+ }
- public void broadcast(UUID chatId, String userName, String message, MessageColor color) {
- chatSessions.get(chatId).broadcast(userName, message, color);
- }
+ public void broadcast(UUID chatId, String userName, String message, MessageColor color) {
+ chatSessions.get(chatId).broadcast(userName, message, color);
+ }
- /**
- *
- * use mainly for announcing that a user connection was lost or that a user has reconnected
- *
- * @param userId
- * @param message
- * @param color
- */
- public void broadcast(UUID userId, String message, MessageColor color) {
- User user = UserManager.getInstance().getUser(userId);
- if (user != null) {
- for (ChatSession chat: chatSessions.values()) {
- if (chat.hasUser(userId))
- chat.broadcast(user.getName(), message, color);
- }
- }
- }
+ /**
+ *
+ * use mainly for announcing that a user connection was lost or that a user has reconnected
+ *
+ * @param userId
+ * @param message
+ * @param color
+ */
+ public void broadcast(UUID userId, String message, MessageColor color) {
+ User user = UserManager.getInstance().getUser(userId);
+ if (user != null) {
+ for (ChatSession chat: chatSessions.values()) {
+ if (chat.hasUser(userId))
+ chat.broadcast(user.getName(), message, color);
+ }
+ }
+ }
- public void removeUser(UUID userId) {
- for (ChatSession chat: chatSessions.values()) {
- chat.kill(userId);
- }
- }
+ public void removeUser(UUID userId) {
+ for (ChatSession chat: chatSessions.values()) {
+ chat.kill(userId);
+ }
+ }
}
diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java
index 41b92d70dd..35ee26e7f4 100644
--- a/Mage.Server/src/main/java/mage/server/ChatSession.java
+++ b/Mage.Server/src/main/java/mage/server/ChatSession.java
@@ -45,58 +45,58 @@ import org.apache.log4j.Logger;
*/
public class ChatSession {
- private final static Logger logger = Logger.getLogger(ChatSession.class);
- private ConcurrentHashMap clients = new ConcurrentHashMap();
- private UUID chatId;
- private DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
+ private final static Logger logger = Logger.getLogger(ChatSession.class);
+ private ConcurrentHashMap clients = new ConcurrentHashMap();
+ private UUID chatId;
+ private DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
- public ChatSession() {
- chatId = UUID.randomUUID();
- }
+ public ChatSession() {
+ chatId = UUID.randomUUID();
+ }
- public void join(UUID userId) {
- User user = UserManager.getInstance().getUser(userId);
- if (user != null) {
- String userName = user.getName();
- clients.put(userId, userName);
- broadcast(userName, " has joined", MessageColor.BLACK);
- logger.info(userName + " joined chat " + chatId);
- }
- }
+ public void join(UUID userId) {
+ User user = UserManager.getInstance().getUser(userId);
+ if (user != null) {
+ String userName = user.getName();
+ clients.put(userId, userName);
+ broadcast(userName, " has joined", MessageColor.BLACK);
+ logger.info(userName + " joined chat " + chatId);
+ }
+ }
- public void kill(UUID userId) {
- if (userId != null && clients.containsKey(userId)) {
- String userName = clients.get(userId);
- clients.remove(userId);
- broadcast(userName, " has left", MessageColor.BLACK);
- logger.info(userName + " has left chat " + chatId);
- }
- }
+ public void kill(UUID userId) {
+ if (userId != null && clients.containsKey(userId)) {
+ String userName = clients.get(userId);
+ clients.remove(userId);
+ broadcast(userName, " has left", MessageColor.BLACK);
+ logger.info(userName + " has left chat " + chatId);
+ }
+ }
- public void broadcast(String userName, String message, MessageColor color) {
- Calendar cal = new GregorianCalendar();
- final String msg = message;
- final String time = timeFormatter.format(cal.getTime());
- final String username = userName;
- logger.debug("Broadcasting '" + msg + "' for " + chatId);
- for (UUID userId: clients.keySet()) {
- User user = UserManager.getInstance().getUser(userId);
- if (user != null)
- user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
- else
- kill(userId);
- }
- }
+ public void broadcast(String userName, String message, MessageColor color) {
+ Calendar cal = new GregorianCalendar();
+ final String msg = message;
+ final String time = timeFormatter.format(cal.getTime());
+ final String username = userName;
+ logger.debug("Broadcasting '" + msg + "' for " + chatId);
+ for (UUID userId: clients.keySet()) {
+ User user = UserManager.getInstance().getUser(userId);
+ if (user != null)
+ user.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
+ else
+ kill(userId);
+ }
+ }
- /**
- * @return the chatId
- */
- public UUID getChatId() {
- return chatId;
- }
+ /**
+ * @return the chatId
+ */
+ public UUID getChatId() {
+ return chatId;
+ }
- public boolean hasUser(UUID userId) {
- return clients.containsKey(userId);
- }
+ public boolean hasUser(UUID userId) {
+ return clients.containsKey(userId);
+ }
}
diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java
index 9d67fc2369..ff3dfc40c7 100644
--- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java
+++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java
@@ -66,61 +66,61 @@ import java.util.concurrent.ExecutorService;
*/
public class MageServerImpl implements MageServer {
- private final static Logger logger = Logger.getLogger(MageServerImpl.class);
- private static ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
+ private final static Logger logger = Logger.getLogger(MageServerImpl.class);
+ private static ExecutorService callExecutor = ThreadExecutor.getInstance().getCallExecutor();
- private String password;
- private boolean testMode;
+ private String password;
+ private boolean testMode;
- public MageServerImpl(String password, boolean testMode) {
- this.password = password;
- this.testMode = testMode;
- ServerMessagesUtil.getInstance().getMessages();
- }
+ public MageServerImpl(String password, boolean testMode) {
+ this.password = password;
+ this.testMode = testMode;
+ ServerMessagesUtil.getInstance().getMessages();
+ }
- @Override
- public boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException {
- try {
- if (version.compareTo(Main.getVersion()) != 0) {
- logger.info("MageVersionException: userName=" + userName + ", version=" + version);
+ @Override
+ public boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException {
+ try {
+ if (version.compareTo(Main.getVersion()) != 0) {
+ logger.info("MageVersionException: userName=" + userName + ", version=" + version);
LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, userName, version.toString(), Main.getVersion().toString(), sessionId);
- throw new MageVersionException(version, Main.getVersion());
- }
- return SessionManager.getInstance().registerUser(sessionId, userName);
- } catch (Exception ex) {
+ throw new MageVersionException(version, Main.getVersion());
+ }
+ return SessionManager.getInstance().registerUser(sessionId, userName);
+ } catch (Exception ex) {
if (ex instanceof MageVersionException)
throw (MageVersionException)ex;
- handleException(ex);
- }
- return false;
- }
+ handleException(ex);
+ }
+ return false;
+ }
- @Override
- public boolean setUserData(final String userName, final String sessionId, final UserDataView userDataView) throws MageException {
+ @Override
+ public boolean setUserData(final String userName, final String sessionId, final UserDataView userDataView) throws MageException {
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
public Boolean execute() throws MageException {
return SessionManager.getInstance().setUserData(userName, sessionId, userDataView);
}
});
- }
+ }
- @Override
- public boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException {
- try {
- if (version.compareTo(Main.getVersion()) != 0)
- throw new MageException("Wrong client version " + version + ", expecting version " + Main.getVersion());
- if (!password.equals(this.password))
- throw new MageException("Wrong password");
- return SessionManager.getInstance().registerAdmin(sessionId);
- } catch (Exception ex) {
- handleException(ex);
- }
- return false;
- }
+ @Override
+ public boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException {
+ try {
+ if (version.compareTo(Main.getVersion()) != 0)
+ throw new MageException("Wrong client version " + version + ", expecting version " + Main.getVersion());
+ if (!password.equals(this.password))
+ throw new MageException("Wrong password");
+ return SessionManager.getInstance().registerAdmin(sessionId);
+ } catch (Exception ex) {
+ handleException(ex);
+ }
+ return false;
+ }
- @Override
- public TableView createTable(final String sessionId, final UUID roomId, final MatchOptions options) throws MageException {
- return executeWithResult("createTable", sessionId, new ActionWithTableViewResult() {
+ @Override
+ public TableView createTable(final String sessionId, final UUID roomId, final MatchOptions options) throws MageException {
+ return executeWithResult("createTable", sessionId, new ActionWithTableViewResult() {
public TableView execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTable(userId, options);
@@ -129,10 +129,10 @@ public class MageServerImpl implements MageServer {
return table;
}
});
- }
+ }
- @Override
- public TableView createTournamentTable(final String sessionId, final UUID roomId, final TournamentOptions options) throws MageException {
+ @Override
+ public TableView createTournamentTable(final String sessionId, final UUID roomId, final TournamentOptions options) throws MageException {
return executeWithResult("createTournamentTable", sessionId, new ActionWithTableViewResult() {
public TableView execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
@@ -142,21 +142,21 @@ public class MageServerImpl implements MageServer {
return table;
}
});
- }
+ }
- @Override
- public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
+ @Override
+ public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
execute("removeTable", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TableManager.getInstance().removeTable(userId, tableId);
}
});
- }
+ }
- @Override
- public boolean joinTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill, final DeckCardLists deckList) throws MageException, GameException {
- return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
+ @Override
+ public boolean joinTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill, final DeckCardLists deckList) throws MageException, GameException {
+ return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
public Boolean execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(userId, tableId, name, playerType, skill, deckList);
@@ -164,11 +164,11 @@ public class MageServerImpl implements MageServer {
return ret;
}
});
- }
+ }
- @Override
- public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill) throws MageException, GameException {
- return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
+ @Override
+ public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill) throws MageException, GameException {
+ return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
public Boolean execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(userId, tableId, name, playerType, skill);
@@ -176,106 +176,106 @@ public class MageServerImpl implements MageServer {
return ret;
}
});
- }
+ }
- @Override
- public boolean submitDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException, GameException {
+ @Override
+ public boolean submitDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException, GameException {
return executeWithResult("submitDeck", sessionId, new ActionWithBooleanResult() {
public Boolean execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
- boolean ret = TableManager.getInstance().submitDeck(userId, tableId, deckList);
- logger.info("Session " + sessionId + " submitted deck");
- return ret;
+ boolean ret = TableManager.getInstance().submitDeck(userId, tableId, deckList);
+ logger.info("Session " + sessionId + " submitted deck");
+ return ret;
}
});
- }
+ }
- @Override
- public void updateDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException, GameException {
- execute("updateDeck", sessionId, new Action() {
+ @Override
+ public void updateDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException, GameException {
+ execute("updateDeck", sessionId, new Action() {
public void execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TableManager.getInstance().updateDeck(userId, tableId, deckList);
logger.debug("Session " + sessionId + " updated deck");
}
});
- }
+ }
@Override
//FIXME: why no sessionId here???
- public List getTables(UUID roomId) throws MageException {
+ public List getTables(UUID roomId) throws MageException {
try {
- return GamesRoomManager.getInstance().getRoom(roomId).getTables();
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
-
- @Override
- //FIXME: why no sessionId here???
- public List getFinishedMatches(UUID roomId) throws MageException {
- try {
- return GamesRoomManager.getInstance().getRoom(roomId).getFinished();
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ return GamesRoomManager.getInstance().getRoom(roomId).getTables();
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
@Override
//FIXME: why no sessionId here???
- public List getConnectedPlayers(UUID roomId) throws MageException {
- try {
- return GamesRoomManager.getInstance().getRoom(roomId).getPlayers();
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public List getFinishedMatches(UUID roomId) throws MageException {
+ try {
+ return GamesRoomManager.getInstance().getRoom(roomId).getFinished();
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public TableView getTable(UUID roomId, UUID tableId) throws MageException {
- try {
- return GamesRoomManager.getInstance().getRoom(roomId).getTable(tableId);
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
-
+ public List getConnectedPlayers(UUID roomId) throws MageException {
+ try {
+ return GamesRoomManager.getInstance().getRoom(roomId).getPlayers();
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
+
+ @Override
+ //FIXME: why no sessionId here???
+ public TableView getTable(UUID roomId, UUID tableId) throws MageException {
+ try {
+ return GamesRoomManager.getInstance().getRoom(roomId).getTable(tableId);
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
+
@Override
public boolean ping(String sessionId) {
return SessionManager.getInstance().extendUserSession(sessionId);
}
- @Override
- public void deregisterClient(final String sessionId) throws MageException {
- execute("deregisterClient", sessionId, new Action() {
+ @Override
+ public void deregisterClient(final String sessionId) throws MageException {
+ execute("deregisterClient", sessionId, new Action() {
public void execute() {
SessionManager.getInstance().disconnect(sessionId, true);
logger.info("Client deregistered ...");
}
});
- }
+ }
- @Override
- public void startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
+ @Override
+ public void startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
execute("startMatch", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
- TableManager.getInstance().startMatch(userId, roomId, tableId);
+ TableManager.getInstance().startMatch(userId, roomId, tableId);
}
});
- }
+ }
- @Override
- public void startChallenge(final String sessionId, final UUID roomId, final UUID tableId, final UUID challengeId) throws MageException {
+ @Override
+ public void startChallenge(final String sessionId, final UUID roomId, final UUID tableId, final UUID challengeId) throws MageException {
execute("startChallenge", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
@@ -284,185 +284,185 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public void startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
+ @Override
+ public void startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
execute("startTournament", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TableManager.getInstance().startTournament(userId, roomId, tableId);
}
});
- }
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public TournamentView getTournament(UUID tournamentId) throws MageException {
- try {
- return TournamentManager.getInstance().getTournamentView(tournamentId);
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public TournamentView getTournament(UUID tournamentId) throws MageException {
+ try {
+ return TournamentManager.getInstance().getTournamentView(tournamentId);
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
- try {
- callExecutor.execute(
- new Runnable() {
- @Override
- public void run() {
- ChatManager.getInstance().broadcast(chatId, userName, message, MessageColor.BLUE);
- }
- }
- );
- }
- catch (Exception ex) {
- handleException(ex);
- }
- }
+ public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
+ try {
+ callExecutor.execute(
+ new Runnable() {
+ @Override
+ public void run() {
+ ChatManager.getInstance().broadcast(chatId, userName, message, MessageColor.BLUE);
+ }
+ }
+ );
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ }
- @Override
- public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException {
+ @Override
+ public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException {
execute("joinChat", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
ChatManager.getInstance().joinChat(chatId, userId);
}
});
- }
+ }
- @Override
- public void leaveChat(final UUID chatId, final String sessionId) throws MageException {
+ @Override
+ public void leaveChat(final UUID chatId, final String sessionId) throws MageException {
execute("leaveChat", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
ChatManager.getInstance().leaveChat(chatId, userId);
}
});
- }
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public UUID getMainRoomId() throws MageException {
- try {
- return GamesRoomManager.getInstance().getMainRoomId();
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public UUID getMainRoomId() throws MageException {
+ try {
+ return GamesRoomManager.getInstance().getMainRoomId();
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public UUID getRoomChatId(UUID roomId) throws MageException {
- try {
- return GamesRoomManager.getInstance().getRoom(roomId).getChatId();
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public UUID getRoomChatId(UUID roomId) throws MageException {
+ try {
+ return GamesRoomManager.getInstance().getRoom(roomId).getChatId();
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
- @Override
- public boolean isTableOwner(final String sessionId, UUID roomId, final UUID tableId) throws MageException {
- return executeWithResult("isTableOwner", sessionId, new ActionWithBooleanResult() {
+ @Override
+ public boolean isTableOwner(final String sessionId, UUID roomId, final UUID tableId) throws MageException {
+ return executeWithResult("isTableOwner", sessionId, new ActionWithBooleanResult() {
public Boolean execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
return TableManager.getInstance().isTableOwner(tableId, userId);
}
});
- }
+ }
- @Override
- public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
+ @Override
+ public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
execute("swapSeats", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TableManager.getInstance().swapSeats(tableId, userId, seatNum1, seatNum2);
}
});
- }
+ }
- @Override
- public void leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
+ @Override
+ public void leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
execute("leaveTable", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
GamesRoomManager.getInstance().getRoom(roomId).leaveTable(userId, tableId);
}
});
- }
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public UUID getTableChatId(UUID tableId) throws MageException {
- try {
- return TableManager.getInstance().getChatId(tableId);
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public UUID getTableChatId(UUID tableId) throws MageException {
+ try {
+ return TableManager.getInstance().getChatId(tableId);
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
- @Override
- public void joinGame(final UUID gameId, final String sessionId) throws MageException {
+ @Override
+ public void joinGame(final UUID gameId, final String sessionId) throws MageException {
execute("joinGame", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
GameManager.getInstance().joinGame(gameId, userId);
}
});
- }
+ }
- @Override
- public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
+ @Override
+ public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
execute("joinDraft", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
DraftManager.getInstance().joinDraft(draftId, userId);
}
});
- }
+ }
- @Override
- public void joinTournament(final UUID tournamentId, final String sessionId) throws MageException {
+ @Override
+ public void joinTournament(final UUID tournamentId, final String sessionId) throws MageException {
execute("joinTournament", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TournamentManager.getInstance().joinTournament(tournamentId, userId);
}
});
- }
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public UUID getGameChatId(UUID gameId) throws MageException {
- try {
- return GameManager.getInstance().getChatId(gameId);
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public UUID getGameChatId(UUID gameId) throws MageException {
+ try {
+ return GameManager.getInstance().getChatId(gameId);
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
- @Override
+ @Override
//FIXME: why no sessionId here???
- public UUID getTournamentChatId(UUID tournamentId) throws MageException {
- try {
- return TournamentManager.getInstance().getChatId(tournamentId);
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public UUID getTournamentChatId(UUID tournamentId) throws MageException {
+ try {
+ return TournamentManager.getInstance().getChatId(tournamentId);
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
@Override
public void sendPlayerUUID(final UUID gameId, final String sessionId, final UUID data) throws MageException {
@@ -474,7 +474,7 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
+ @Override
public void sendPlayerString(final UUID gameId, final String sessionId, final String data) throws MageException {
execute("sendPlayerString", sessionId, new Action() {
public void execute() {
@@ -482,20 +482,20 @@ public class MageServerImpl implements MageServer {
user.sendPlayerString(gameId, data);
}
});
- }
+ }
- @Override
- public void sendPlayerBoolean(final UUID gameId, final String sessionId, final Boolean data) throws MageException {
+ @Override
+ public void sendPlayerBoolean(final UUID gameId, final String sessionId, final Boolean data) throws MageException {
execute("sendPlayerBoolean", sessionId, new Action() {
public void execute() {
User user = SessionManager.getInstance().getUser(sessionId);
user.sendPlayerBoolean(gameId, data);
}
});
- }
+ }
- @Override
- public void sendPlayerInteger(final UUID gameId, final String sessionId, final Integer data) throws MageException {
+ @Override
+ public void sendPlayerInteger(final UUID gameId, final String sessionId, final Integer data) throws MageException {
execute("sendPlayerInteger", sessionId, new Action() {
public void execute() {
User user = SessionManager.getInstance().getUser(sessionId);
@@ -504,15 +504,15 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public DraftPickView sendCardPick(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
- return executeWithResult("sendCardPick", sessionId, new ActionWithNullNegativeResult() {
+ @Override
+ public DraftPickView sendCardPick(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
+ return executeWithResult("sendCardPick", sessionId, new ActionWithNullNegativeResult() {
public DraftPickView execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
- return DraftManager.getInstance().sendCardPick(draftId, userId, cardPick);
+ return DraftManager.getInstance().sendCardPick(draftId, userId, cardPick);
}
});
- }
+ }
@Override
public void concedeGame(final UUID gameId, final String sessionId) throws MageException {
@@ -524,15 +524,15 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
- return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
+ @Override
+ public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
+ return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
public Boolean execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
- return GamesRoomManager.getInstance().getRoom(roomId).watchTable(userId, tableId);
+ return GamesRoomManager.getInstance().getRoom(roomId).watchTable(userId, tableId);
}
});
- }
+ }
@Override
public void watchGame(final UUID gameId, final String sessionId) throws MageException {
@@ -554,15 +554,15 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public void replayGame(final UUID gameId, final String sessionId) throws MageException {
+ @Override
+ public void replayGame(final UUID gameId, final String sessionId) throws MageException {
execute("replayGame", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
ReplayManager.getInstance().replayGame(gameId, userId);
}
});
- }
+ }
@Override
public void startReplay(final UUID gameId, final String sessionId) throws MageException {
@@ -574,17 +574,17 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public void stopReplay(final UUID gameId, final String sessionId) throws MageException {
+ @Override
+ public void stopReplay(final UUID gameId, final String sessionId) throws MageException {
execute("stopReplay", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
ReplayManager.getInstance().stopReplay(gameId, userId);
}
});
- }
+ }
- @Override
+ @Override
public void nextPlay(final UUID gameId, final String sessionId) throws MageException {
execute("nextPlay", sessionId, new Action() {
public void execute() {
@@ -594,15 +594,15 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public void previousPlay(final UUID gameId, final String sessionId) throws MageException {
+ @Override
+ public void previousPlay(final UUID gameId, final String sessionId) throws MageException {
execute("previousPlay", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
ReplayManager.getInstance().previousPlay(gameId, userId);
}
});
- }
+ }
@Override
public void skipForward(final UUID gameId, final String sessionId, final int moves) throws MageException {
@@ -616,21 +616,21 @@ public class MageServerImpl implements MageServer {
@Override
//TODO: check how often it is used
- public ServerState getServerState() throws MageException {
- try {
- return new ServerState(
- GameFactory.getInstance().getGameTypes(),
- TournamentFactory.getInstance().getTournamentTypes(),
- PlayerFactory.getInstance().getPlayerTypes().toArray(new String[0]),
- DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[0]),
- testMode,
- Main.getVersion());
- }
- catch (Exception ex) {
- handleException(ex);
- }
- return null;
- }
+ public ServerState getServerState() throws MageException {
+ try {
+ return new ServerState(
+ GameFactory.getInstance().getGameTypes(),
+ TournamentFactory.getInstance().getTournamentTypes(),
+ PlayerFactory.getInstance().getPlayerTypes().toArray(new String[0]),
+ DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[0]),
+ testMode,
+ Main.getVersion());
+ }
+ catch (Exception ex) {
+ handleException(ex);
+ }
+ return null;
+ }
@Override
public void cheat(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException {
@@ -645,7 +645,7 @@ public class MageServerImpl implements MageServer {
}
@Override
- public boolean cheat(final UUID gameId, final String sessionId, final UUID playerId, final String cardName) throws MageException {
+ public boolean cheat(final UUID gameId, final String sessionId, final UUID playerId, final String cardName) throws MageException {
return executeWithResult("cheatOne", sessionId, new ActionWithBooleanResult() {
public Boolean execute() {
if (testMode) {
@@ -655,16 +655,16 @@ public class MageServerImpl implements MageServer {
return false;
}
});
- }
+ }
- public void handleException(Exception ex) throws MageException {
- logger.fatal("", ex);
- throw new MageException("Server error: " + ex.getMessage());
- }
+ public void handleException(Exception ex) throws MageException {
+ logger.fatal("", ex);
+ throw new MageException("Server error: " + ex.getMessage());
+ }
- @Override
+ @Override
public GameView getGameView(final UUID gameId, final String sessionId, final UUID playerId) throws MageException {
- return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult() {
+ return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult() {
public GameView execute() throws MageException {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
return GameManager.getInstance().getGameView(gameId, userId, playerId);
@@ -672,8 +672,8 @@ public class MageServerImpl implements MageServer {
});
}
- @Override
- public List getUsers(String sessionId) throws MageException {
+ @Override
+ public List getUsers(String sessionId) throws MageException {
return executeWithResult("getUsers", sessionId, new ActionWithNullNegativeResult>() {
public List execute() throws MageException {
List users = new ArrayList();
@@ -683,35 +683,35 @@ public class MageServerImpl implements MageServer {
return users;
}
}, true);
- }
+ }
- @Override
- public void disconnectUser(final String sessionId, final String userSessionId) throws MageException {
+ @Override
+ public void disconnectUser(final String sessionId, final String userSessionId) throws MageException {
execute("disconnectUser", sessionId, new Action() {
public void execute() {
SessionManager.getInstance().disconnectUser(sessionId, userSessionId);
}
});
- }
+ }
- @Override
- public void removeTable(final String sessionId, final UUID tableId) throws MageException {
+ @Override
+ public void removeTable(final String sessionId, final UUID tableId) throws MageException {
execute("removeTable", sessionId, new Action() {
public void execute() {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
TableManager.getInstance().removeTable(userId, tableId);
}
});
- }
+ }
- @Override
- public Object getServerMessagesCompressed(String sessionId) throws MageException {
- return executeWithResult("getGameView", sessionId, new ActionWithNullNegativeResult