mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
refactor: improved and reorganized client-server api, added additional logs, fixed miss admin checks for some commands
This commit is contained in:
parent
e43e918c67
commit
75958e3710
21 changed files with 371 additions and 364 deletions
|
|
@ -26,13 +26,12 @@ import java.util.*;
|
||||||
/**
|
/**
|
||||||
* Network: client side session
|
* Network: client side session
|
||||||
*
|
*
|
||||||
* Only one session/server per GUI's client
|
* Only one session/server per GUI's client supports
|
||||||
*
|
*
|
||||||
* Created by IGOUDT on 15-9-2016.
|
* @author IGOUDT
|
||||||
*/
|
*/
|
||||||
public final class SessionHandler {
|
public final class SessionHandler {
|
||||||
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(SessionHandler.class);
|
private static final Logger logger = Logger.getLogger(SessionHandler.class);
|
||||||
|
|
||||||
private static Session session;
|
private static Session session;
|
||||||
|
|
@ -65,7 +64,7 @@ public final class SessionHandler {
|
||||||
|
|
||||||
public static boolean connect(Connection connection) {
|
public static boolean connect(Connection connection) {
|
||||||
lastConnectError = "";
|
lastConnectError = "";
|
||||||
if (session.connect(connection)) {
|
if (session.connectStart(connection)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
lastConnectError = session.getLastError();
|
lastConnectError = session.getLastError();
|
||||||
|
|
@ -78,11 +77,11 @@ public final class SessionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean stopConnecting() {
|
public static boolean stopConnecting() {
|
||||||
return session.stopConnecting();
|
return session.connectAbort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disconnect(boolean showmessage) {
|
public static void disconnect(boolean showmessage) {
|
||||||
session.disconnect(showmessage);
|
session.connectStop(showmessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerAction(PlayerAction playerAction, UUID gameId, Object relatedUserId) {
|
public static void sendPlayerAction(PlayerAction playerAction, UUID gameId, Object relatedUserId) {
|
||||||
|
|
@ -377,14 +376,14 @@ public final class SessionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean emailAuthToken(Connection connection) {
|
public static boolean emailAuthToken(Connection connection) {
|
||||||
return session.emailAuthToken(connection);
|
return session.sendAuthSendTokenToEmail(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean resetPassword(Connection connection) {
|
public static boolean resetPassword(Connection connection) {
|
||||||
return session.resetPassword(connection);
|
return session.sendAuthResetPassword(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean register(Connection connection) {
|
public static boolean register(Connection connection) {
|
||||||
return session.register(connection);
|
return session.sendAuthRegister(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
for (TablePlayerPanel player : players) {
|
for (TablePlayerPanel player : players) {
|
||||||
if (player.getPlayerType() != PlayerType.HUMAN) {
|
if (player.getPlayerType() != PlayerType.HUMAN) {
|
||||||
if (!player.joinTable(roomId, table.getTableId())) {
|
if (!player.joinTable(roomId, table.getTableId())) {
|
||||||
// error message must be send by the server
|
// error message must be sent by a server
|
||||||
SessionHandler.removeTable(roomId, table.getTableId());
|
SessionHandler.removeTable(roomId, table.getTableId());
|
||||||
table = null;
|
table = null;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class MultiConnectTest {
|
||||||
connection.setPort(17171);
|
connection.setPort(17171);
|
||||||
connection.setProxyType(Connection.ProxyType.NONE);
|
connection.setProxyType(Connection.ProxyType.NONE);
|
||||||
|
|
||||||
session.connect(connection);
|
session.connectStart(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import mage.interfaces.callback.CallbackClient;
|
||||||
import mage.utils.MageVersion;
|
import mage.utils.MageVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Network: client side commands to process from a server
|
||||||
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public interface MageClient extends CallbackClient {
|
public interface MageClient extends CallbackClient {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.interfaces;
|
package mage.interfaces;
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
|
|
@ -20,99 +19,99 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Network: server side commands to process from a client
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||||
*/
|
*/
|
||||||
public interface MageServer {
|
public interface MageServer {
|
||||||
|
|
||||||
// registers a user to the user DB.
|
// registers a user to the user DB.
|
||||||
boolean registerUser(String sessionId, String userName, String password, String email) throws MageException;
|
boolean authRegister(String sessionId, String userName, String password, String email) throws MageException;
|
||||||
|
|
||||||
boolean emailAuthToken(String sessionId, String email) throws MageException;
|
boolean authSendTokenToEmail(String sessionId, String email) throws MageException;
|
||||||
|
|
||||||
boolean resetPassword(String sessionId, String email, String authToken, String password) throws MageException;
|
boolean authResetPassword(String sessionId, String email, String authToken, String password) throws MageException;
|
||||||
|
|
||||||
boolean connectUser(String userName, String password, String sessionId, MageVersion version, String userIdStr) throws MageException;
|
boolean connectUser(String userName, String password, String sessionId, MageVersion version, String userIdStr) throws MageException;
|
||||||
|
|
||||||
boolean connectAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
boolean connectAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||||
|
|
||||||
// update methods
|
boolean connectSetUserData(String userName, String sessionId, UserData userData, String clientVersion, String userIdStr) throws MageException;
|
||||||
List<ExpansionInfo> getMissingExpansionData(List<String> codes);
|
|
||||||
|
|
||||||
List<CardInfo> getMissingCardsData(List<String> classNames);
|
boolean ping(String sessionId, String pingInfo) throws MageException;
|
||||||
|
|
||||||
|
void serverAddFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
||||||
|
|
||||||
// user methods
|
Object serverGetPromotionMessages(String sessionId) throws MageException;
|
||||||
boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion, String userIdStr) throws MageException;
|
|
||||||
|
|
||||||
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
// sync cards send sets db
|
||||||
|
// TODO: outdated, no more client/server sync, can be removed?
|
||||||
|
List<ExpansionInfo> syncGetMissingExpansionData(List<String> codes);
|
||||||
|
List<CardInfo> syncGetMissingCardsData(List<String> classNames);
|
||||||
|
|
||||||
// server state methods
|
// server state methods
|
||||||
ServerState getServerState() throws MageException;
|
ServerState serverGetState() throws MageException;
|
||||||
|
|
||||||
List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException;
|
UUID serverGetMainRoomId() throws MageException;
|
||||||
|
|
||||||
List<MatchView> getFinishedMatches(UUID roomId) throws MageException;
|
List<RoomUsersView> roomGetUsers(UUID roomId) throws MageException;
|
||||||
|
|
||||||
Object getServerMessagesCompressed(String sessionId) throws MageException; // messages of the day
|
List<MatchView> roomGetFinishedMatches(UUID roomId) throws MageException;
|
||||||
|
|
||||||
// ping - extends session
|
TableView roomCreateTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
||||||
boolean ping(String sessionId, String pingInfo) throws MageException;
|
|
||||||
|
|
||||||
//table methods
|
TableView roomCreateTournament(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException;
|
||||||
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
|
|
||||||
|
|
||||||
TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException;
|
boolean roomJoinTable(String sessionId, UUID roomId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
|
||||||
|
|
||||||
boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
|
boolean roomJoinTournament(String sessionId, UUID roomId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
|
||||||
|
|
||||||
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, PlayerType playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
|
boolean deckSubmit(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||||
|
|
||||||
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
void deckSave(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
||||||
|
|
||||||
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
|
boolean roomWatchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
boolean roomWatchTournament(String sessionId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean watchTournamentTable(String sessionId, UUID tableId) throws MageException;
|
boolean roomLeaveTableOrTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean leaveTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
void tableSwapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
||||||
|
|
||||||
void swapSeats(String sessionId, UUID roomId, UUID tableId, int seatNum1, int seatNum2) throws MageException;
|
void tableRemove(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
void removeTable(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
boolean tableIsOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
TableView roomGetTableById(UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
List<TableView> roomGetAllTables(UUID roomId) throws MageException;
|
||||||
|
|
||||||
List<TableView> getTables(UUID roomId) throws MageException;
|
void chatSendMessage(UUID chatId, String userName, String message) throws MageException;
|
||||||
|
|
||||||
//chat methods
|
void chatJoin(UUID chatId, String sessionId, String userName) throws MageException;
|
||||||
void sendChatMessage(UUID chatId, String userName, String message) throws MageException;
|
|
||||||
|
|
||||||
void joinChat(UUID chatId, String sessionId, String userName) throws MageException;
|
void chatLeave(UUID chatId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
UUID chatFindByGame(UUID gameId) throws MageException;
|
||||||
|
|
||||||
UUID getTableChatId(UUID tableId) throws MageException;
|
UUID chatFindByTable(UUID tableId) throws MageException;
|
||||||
|
|
||||||
UUID getGameChatId(UUID gameId) throws MageException;
|
UUID chatFindByTournament(UUID tournamentId) throws MageException;
|
||||||
|
|
||||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
UUID chatFindByRoom(UUID roomId) throws MageException;
|
||||||
|
|
||||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
boolean matchStart(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
//room methods
|
void matchQuit(UUID gameId, String sessionId) throws MageException;
|
||||||
UUID getMainRoomId() throws MageException;
|
|
||||||
|
|
||||||
//game methods
|
void gameJoin(UUID gameId, String sessionId) throws MageException;
|
||||||
boolean startMatch(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
|
||||||
|
|
||||||
void joinGame(UUID gameId, String sessionId) throws MageException;
|
@Deprecated // TODO: implement GameView request on miss client side data, e.g. on reconnect (empty player panels bug)?
|
||||||
|
GameView gameGetView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
||||||
|
|
||||||
boolean watchGame(UUID gameId, String sessionId) throws MageException;
|
boolean gameWatchStart(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void stopWatching(UUID gameId, String sessionId) throws MageException;
|
void gameWatchStop(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
|
void sendPlayerUUID(UUID gameId, String sessionId, UUID data) throws MageException;
|
||||||
|
|
||||||
|
|
@ -124,69 +123,58 @@ public interface MageServer {
|
||||||
|
|
||||||
void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
|
void sendPlayerManaType(UUID gameId, UUID playerId, String sessionId, ManaType data) throws MageException;
|
||||||
|
|
||||||
void quitMatch(UUID gameId, String sessionId) throws MageException;
|
|
||||||
|
|
||||||
GameView getGameView(UUID gameId, String sessionId, UUID playerId) throws MageException;
|
|
||||||
|
|
||||||
// priority, undo, concede, mana pool
|
// priority, undo, concede, mana pool
|
||||||
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
|
void sendPlayerAction(PlayerAction playerAction, UUID gameId, String sessionId, Object data) throws MageException;
|
||||||
|
|
||||||
//tournament methods
|
DraftPickView sendDraftCardPick(UUID draftId, String sessionId, UUID cardId, Set<UUID> hiddenCards) throws MageException;
|
||||||
boolean startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
|
||||||
|
|
||||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
void sendDraftCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
||||||
|
|
||||||
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
|
boolean tournamentStart(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
void tournamentJoin(UUID draftId, String sessionId) throws MageException;
|
||||||
|
|
||||||
//draft methods
|
void tournamentQuit(UUID tournamentId, String sessionId) throws MageException;
|
||||||
void joinDraft(UUID draftId, String sessionId) throws MageException;
|
|
||||||
|
|
||||||
void quitDraft(UUID draftId, String sessionId) throws MageException;
|
TournamentView tournamentFindById(UUID tournamentId) throws MageException;
|
||||||
|
|
||||||
DraftPickView sendCardPick(UUID draftId, String sessionId, UUID cardId, Set<UUID> hiddenCards) throws MageException;
|
void draftJoin(UUID draftId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void sendCardMark(UUID draftId, String sessionId, UUID cardId) throws MageException;
|
void draftQuit(UUID draftId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void setBoosterLoaded(UUID draftId, String sessionId) throws MageException;
|
void draftSetBoosterLoaded(UUID draftId, String sessionId) throws MageException;
|
||||||
|
|
||||||
//challenge methods
|
void replayInit(UUID gameId, String sessionId) throws MageException;
|
||||||
// void startChallenge(String sessionId, UUID roomId, UUID tableId, UUID challengeId) throws MageException;
|
|
||||||
//replay methods
|
|
||||||
void replayGame(UUID gameId, String sessionId) throws MageException;
|
|
||||||
|
|
||||||
void startReplay(UUID gameId, String sessionId) throws MageException;
|
void replayStart(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void stopReplay(UUID gameId, String sessionId) throws MageException;
|
void replayStop(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void nextPlay(UUID gameId, String sessionId) throws MageException;
|
void replayNext(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void previousPlay(UUID gameId, String sessionId) throws MageException;
|
void replayPrevious(UUID gameId, String sessionId) throws MageException;
|
||||||
|
|
||||||
void skipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
void replaySkipForward(UUID gameId, String sessionId, int moves) throws MageException;
|
||||||
|
|
||||||
//test methods
|
void cheatMultiple(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
||||||
void cheat(UUID gameId, String sessionId, UUID playerId, DeckCardLists deckList) throws MageException;
|
|
||||||
|
|
||||||
boolean cheat(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
boolean cheatOne(UUID gameId, String sessionId, UUID playerId, String cardName) throws MageException;
|
||||||
|
|
||||||
//admin methods
|
List<UserView> adminGetUsers(String sessionId) throws MageException;
|
||||||
List<UserView> getUsers(String sessionId) throws MageException;
|
|
||||||
|
|
||||||
void disconnectUser(String sessionId, String userSessionId) throws MageException;
|
void adminDisconnectUser(String sessionId, String userSessionId) throws MageException;
|
||||||
|
|
||||||
void endUserSession(String sessionId, String userSessionId) throws MageException;
|
void adminEndUserSession(String sessionId, String userSessionId) throws MageException;
|
||||||
|
|
||||||
void muteUser(String sessionId, String userName, long durationMinutes) throws MageException;
|
void adminMuteUser(String sessionId, String userName, long durationMinutes) throws MageException;
|
||||||
|
|
||||||
void lockUser(String sessionId, String userName, long durationMinutes) throws MageException;
|
void adminLockUser(String sessionId, String userName, long durationMinutes) throws MageException;
|
||||||
|
|
||||||
void setActivation(String sessionId, String userName, boolean active) throws MageException;
|
void adminActivateUser(String sessionId, String userName, boolean active) throws MageException;
|
||||||
|
|
||||||
void toggleActivation(String sessionId, String userName) throws MageException;
|
void adminToggleActivateUser(String sessionId, String userName) throws MageException;
|
||||||
|
|
||||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
void adminTableRemove(String sessionId, UUID tableId) throws MageException;
|
||||||
|
|
||||||
void sendBroadcastMessage(String sessionId, String message) throws MageException;
|
void adminSendBroadcastMessage(String sessionId, String message) throws MageException;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.remote;
|
package mage.remote;
|
||||||
|
|
||||||
import mage.remote.interfaces.ChatSession;
|
import mage.remote.interfaces.ChatSession;
|
||||||
|
|
@ -13,11 +12,11 @@ import mage.remote.interfaces.ServerState;
|
||||||
import mage.remote.interfaces.Testable;
|
import mage.remote.interfaces.Testable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracted interface for SessionImpl class.
|
* Network: client/server session
|
||||||
*
|
*
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public interface Session extends ClientData, Connect, GamePlay, GameTypes, ServerState, ChatSession, Feedback, PlayerActions, Replays, Testable {
|
public interface Session extends ClientData, Connect, GamePlay, GameTypes, ServerState, ChatSession, Feedback, PlayerActions, Replays, Testable {
|
||||||
|
|
||||||
public void appendJsonLog(ActionData actionData);
|
void appendJsonLog(ActionData actionData);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ public class SessionImpl implements Session {
|
||||||
showMessageToUser(addMessage + (ex.getMessage() != null ? ex.getMessage() : ""));
|
showMessageToUser(addMessage + (ex.getMessage() != null ? ex.getMessage() : ""));
|
||||||
} catch (MageVersionException ex) {
|
} catch (MageVersionException ex) {
|
||||||
logger.warn("Connect: wrong versions");
|
logger.warn("Connect: wrong versions");
|
||||||
disconnect(false);
|
connectStop(false);
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
showMessageToUser(ex.getMessage());
|
showMessageToUser(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
@ -188,26 +188,26 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.fatal("Connect: FAIL", t);
|
logger.fatal("Connect: FAIL", t);
|
||||||
disconnect(false);
|
connectStop(false);
|
||||||
if (!canceled) {
|
if (!canceled) {
|
||||||
showMessageToUser(t.getMessage());
|
showMessageToUser(t.getMessage());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lastRemotingTask = null;
|
lastRemotingTask = null;
|
||||||
if (closeConnectionOnFinish) {
|
if (closeConnectionOnFinish) {
|
||||||
disconnect(false); // it's ok on mutiple calls
|
connectStop(false); // it's ok on mutiple calls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean register(final Connection connection) {
|
public synchronized boolean sendAuthRegister(final Connection connection) {
|
||||||
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(true, true, new RemotingTask() {
|
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(true, true, new RemotingTask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean work() throws Throwable {
|
public boolean work() throws Throwable {
|
||||||
logger.info("Registration: username " + getUserName() + " for email " + getEmail());
|
logger.info("Registration: username " + getUserName() + " for email " + getEmail());
|
||||||
boolean result = server.registerUser(sessionId, connection.getUsername(), connection.getPassword(), connection.getEmail());
|
boolean result = server.authRegister(sessionId, connection.getUsername(), connection.getPassword(), connection.getEmail());
|
||||||
logger.info("Registration: " + (result ? "DONE, check your email for new password" : "FAIL"));
|
logger.info("Registration: " + (result ? "DONE, check your email for new password" : "FAIL"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -215,12 +215,12 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean emailAuthToken(final Connection connection) {
|
public synchronized boolean sendAuthSendTokenToEmail(final Connection connection) {
|
||||||
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(true, true, new RemotingTask() {
|
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(true, true, new RemotingTask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean work() throws Throwable {
|
public boolean work() throws Throwable {
|
||||||
logger.info("Auth request: requesting auth token for username " + getUserName() + " to email " + getEmail());
|
logger.info("Auth request: requesting auth token for username " + getUserName() + " to email " + getEmail());
|
||||||
boolean result = server.emailAuthToken(sessionId, connection.getEmail());
|
boolean result = server.authSendTokenToEmail(sessionId, connection.getEmail());
|
||||||
logger.info("Auth request: " + (result ? "DONE, check your email for auth token" : "FAIL"));
|
logger.info("Auth request: " + (result ? "DONE, check your email for auth token" : "FAIL"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -228,12 +228,12 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean resetPassword(final Connection connection) {
|
public synchronized boolean sendAuthResetPassword(final Connection connection) {
|
||||||
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(true, true, new RemotingTask() {
|
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(true, true, new RemotingTask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean work() throws Throwable {
|
public boolean work() throws Throwable {
|
||||||
logger.info("Password reset: reseting password for username " + getUserName());
|
logger.info("Password reset: reseting password for username " + getUserName());
|
||||||
boolean result = server.resetPassword(sessionId, connection.getEmail(), connection.getAuthToken(), connection.getPassword());
|
boolean result = server.authResetPassword(sessionId, connection.getEmail(), connection.getAuthToken(), connection.getPassword());
|
||||||
logger.info("Password reset: " + (result ? "DONE, now you can login with new password" : "FAIL"));
|
logger.info("Password reset: " + (result ? "DONE, now you can login with new password" : "FAIL"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +241,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean connect(final Connection connection) {
|
public synchronized boolean connectStart(final Connection connection) {
|
||||||
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(false, true, new RemotingTask() {
|
return doRemoteConnection(connection) && doRemoteWorkAndHandleErrors(false, true, new RemotingTask() {
|
||||||
@Override
|
@Override
|
||||||
public boolean work() throws Throwable {
|
public boolean work() throws Throwable {
|
||||||
|
|
@ -257,7 +257,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
serverState = server.getServerState();
|
serverState = server.serverGetState();
|
||||||
|
|
||||||
// client side check for incompatible versions
|
// client side check for incompatible versions
|
||||||
if (client.getVersion().compareTo(serverState.getVersion()) != 0) {
|
if (client.getVersion().compareTo(serverState.getVersion()) != 0) {
|
||||||
|
|
@ -265,7 +265,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connection.getUsername().equals("Admin")) {
|
if (!connection.getUsername().equals("Admin")) {
|
||||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
|
server.connectSetUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
|
||||||
updateDatabase(connection.isForceDBComparison(), serverState);
|
updateDatabase(connection.isForceDBComparison(), serverState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,7 +286,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopConnecting() {
|
public boolean connectAbort() {
|
||||||
canceled = true;
|
canceled = true;
|
||||||
if (lastRemotingTask != null) {
|
if (lastRemotingTask != null) {
|
||||||
lastRemotingTask.cancel();
|
lastRemotingTask.cancel();
|
||||||
|
|
@ -297,7 +297,7 @@ public class SessionImpl implements Session {
|
||||||
private boolean doRemoteConnection(final Connection connection) {
|
private boolean doRemoteConnection(final Connection connection) {
|
||||||
// connect to server and setup all data, can be canceled
|
// connect to server and setup all data, can be canceled
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
disconnect(true);
|
connectStop(true);
|
||||||
}
|
}
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.canceled = false;
|
this.canceled = false;
|
||||||
|
|
@ -461,7 +461,7 @@ public class SessionImpl implements Session {
|
||||||
if (result) {
|
if (result) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
disconnect(false);
|
connectStop(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -474,7 +474,7 @@ public class SessionImpl implements Session {
|
||||||
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
|
long expansionDBVersion = ExpansionRepository.instance.getContentVersionFromDB();
|
||||||
if (forceDBComparison || serverState.getExpansionsContentVersion() > expansionDBVersion) {
|
if (forceDBComparison || serverState.getExpansionsContentVersion() > expansionDBVersion) {
|
||||||
List<String> setCodes = ExpansionRepository.instance.getSetCodes();
|
List<String> setCodes = ExpansionRepository.instance.getSetCodes();
|
||||||
List<ExpansionInfo> expansions = server.getMissingExpansionData(setCodes);
|
List<ExpansionInfo> expansions = server.syncGetMissingExpansionData(setCodes);
|
||||||
logger.info("DB: updating sets... Found new: " + expansions.size());
|
logger.info("DB: updating sets... Found new: " + expansions.size());
|
||||||
ExpansionRepository.instance.saveSets(expansions, null, serverState.getExpansionsContentVersion());
|
ExpansionRepository.instance.saveSets(expansions, null, serverState.getExpansionsContentVersion());
|
||||||
}
|
}
|
||||||
|
|
@ -483,7 +483,7 @@ public class SessionImpl implements Session {
|
||||||
long cardDBVersion = CardRepository.instance.getContentVersionFromDB();
|
long cardDBVersion = CardRepository.instance.getContentVersionFromDB();
|
||||||
if (forceDBComparison || serverState.getCardsContentVersion() > cardDBVersion) {
|
if (forceDBComparison || serverState.getCardsContentVersion() > cardDBVersion) {
|
||||||
List<String> classNames = CardRepository.instance.getClassNames();
|
List<String> classNames = CardRepository.instance.getClassNames();
|
||||||
List<CardInfo> cards = server.getMissingCardsData(classNames);
|
List<CardInfo> cards = server.syncGetMissingCardsData(classNames);
|
||||||
logger.info("DB: updating cards... Found new: " + cards.size());
|
logger.info("DB: updating cards... Found new: " + cards.size());
|
||||||
CardRepository.instance.saveCards(cards, serverState.getCardsContentVersion());
|
CardRepository.instance.saveCards(cards, serverState.getCardsContentVersion());
|
||||||
}
|
}
|
||||||
|
|
@ -524,7 +524,7 @@ public class SessionImpl implements Session {
|
||||||
* ask the user if they want to try to reconnect
|
* ask the user if they want to try to reconnect
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void disconnect(boolean askForReconnect) {
|
public synchronized void connectStop(boolean askForReconnect) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
logger.info("Disconnecting...");
|
logger.info("Disconnecting...");
|
||||||
sessionState = SessionState.DISCONNECTING;
|
sessionState = SessionState.DISCONNECTING;
|
||||||
|
|
@ -556,7 +556,7 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void reconnect(Throwable throwable) {
|
public synchronized void connectReconnect(Throwable throwable) {
|
||||||
client.disconnected(true);
|
client.disconnected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,7 +564,7 @@ public class SessionImpl implements Session {
|
||||||
public synchronized boolean sendFeedback(String title, String type, String message, String email) {
|
public synchronized boolean sendFeedback(String title, String type, String message, String email) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
try {
|
try {
|
||||||
server.sendFeedbackMessage(sessionId, connection.getUsername(), title, type, message, email);
|
server.serverAddFeedbackMessage(sessionId, connection.getUsername(), title, type, message, email);
|
||||||
return true;
|
return true;
|
||||||
} catch (MageException e) {
|
} catch (MageException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
|
|
@ -592,7 +592,7 @@ public class SessionImpl implements Session {
|
||||||
@Override
|
@Override
|
||||||
public void handleConnectionException(Throwable throwable, Client client) {
|
public void handleConnectionException(Throwable throwable, Client client) {
|
||||||
logger.info("Connect: lost connection to server.", throwable);
|
logger.info("Connect: lost connection to server.", throwable);
|
||||||
reconnect(throwable);
|
connectReconnect(throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -654,7 +654,7 @@ public class SessionImpl implements Session {
|
||||||
public UUID getMainRoomId() {
|
public UUID getMainRoomId() {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getMainRoomId();
|
return server.serverGetMainRoomId();
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -666,7 +666,7 @@ public class SessionImpl implements Session {
|
||||||
public Optional<UUID> getRoomChatId(UUID roomId) {
|
public Optional<UUID> getRoomChatId(UUID roomId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return Optional.of(server.getRoomChatId(roomId));
|
return Optional.of(server.chatFindByRoom(roomId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -678,7 +678,7 @@ public class SessionImpl implements Session {
|
||||||
public Optional<UUID> getTableChatId(UUID tableId) {
|
public Optional<UUID> getTableChatId(UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return Optional.of(server.getTableChatId(tableId));
|
return Optional.of(server.chatFindByTable(tableId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -690,7 +690,7 @@ public class SessionImpl implements Session {
|
||||||
public Optional<UUID> getGameChatId(UUID gameId) {
|
public Optional<UUID> getGameChatId(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return Optional.of(server.getGameChatId(gameId));
|
return Optional.of(server.chatFindByGame(gameId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -704,7 +704,7 @@ public class SessionImpl implements Session {
|
||||||
public Optional<TableView> getTable(UUID roomId, UUID tableId) {
|
public Optional<TableView> getTable(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return Optional.of(server.getTable(roomId, tableId));
|
return Optional.of(server.roomGetTableById(roomId, tableId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -716,7 +716,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean watchTable(UUID roomId, UUID tableId) {
|
public boolean watchTable(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.watchTable(sessionId, roomId, tableId);
|
server.roomWatchTable(sessionId, roomId, tableId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -731,7 +731,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean watchTournamentTable(UUID tableId) {
|
public boolean watchTournamentTable(UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.watchTournamentTable(sessionId, tableId);
|
server.roomWatchTournament(sessionId, tableId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -751,7 +751,7 @@ public class SessionImpl implements Session {
|
||||||
deckList.setCardLayout(null);
|
deckList.setCardLayout(null);
|
||||||
deckList.setSideboardLayout(null);
|
deckList.setSideboardLayout(null);
|
||||||
}
|
}
|
||||||
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
return server.roomJoinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
handleGameException(ex);
|
handleGameException(ex);
|
||||||
|
|
@ -772,7 +772,7 @@ public class SessionImpl implements Session {
|
||||||
deckList.setCardLayout(null);
|
deckList.setCardLayout(null);
|
||||||
deckList.setSideboardLayout(null);
|
deckList.setSideboardLayout(null);
|
||||||
}
|
}
|
||||||
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
return server.roomJoinTournament(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
handleGameException(ex);
|
handleGameException(ex);
|
||||||
|
|
@ -788,7 +788,7 @@ public class SessionImpl implements Session {
|
||||||
public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
|
public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getTables(roomId);
|
return server.roomGetAllTables(roomId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -803,7 +803,7 @@ public class SessionImpl implements Session {
|
||||||
public Collection<MatchView> getFinishedMatches(UUID roomId) throws MageRemoteException {
|
public Collection<MatchView> getFinishedMatches(UUID roomId) throws MageRemoteException {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getFinishedMatches(roomId);
|
return server.roomGetFinishedMatches(roomId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -818,7 +818,7 @@ public class SessionImpl implements Session {
|
||||||
public Collection<RoomUsersView> getRoomUsers(UUID roomId) throws MageRemoteException {
|
public Collection<RoomUsersView> getRoomUsers(UUID roomId) throws MageRemoteException {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getRoomUsers(roomId);
|
return server.roomGetUsers(roomId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -833,7 +833,7 @@ public class SessionImpl implements Session {
|
||||||
public TournamentView getTournament(UUID tournamentId) throws MageRemoteException {
|
public TournamentView getTournament(UUID tournamentId) throws MageRemoteException {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getTournament(tournamentId);
|
return server.tournamentFindById(tournamentId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -848,7 +848,7 @@ public class SessionImpl implements Session {
|
||||||
public Optional<UUID> getTournamentChatId(UUID tournamentId) {
|
public Optional<UUID> getTournamentChatId(UUID tournamentId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return Optional.of(server.getTournamentChatId(tournamentId));
|
return Optional.of(server.chatFindByTournament(tournamentId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -974,7 +974,7 @@ public class SessionImpl implements Session {
|
||||||
public DraftPickView sendCardPick(UUID draftId, UUID cardId, Set<UUID> hiddenCards) {
|
public DraftPickView sendCardPick(UUID draftId, UUID cardId, Set<UUID> hiddenCards) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.sendCardPick(draftId, sessionId, cardId, hiddenCards);
|
return server.sendDraftCardPick(draftId, sessionId, cardId, hiddenCards);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -988,7 +988,7 @@ public class SessionImpl implements Session {
|
||||||
public DraftPickView sendCardMark(UUID draftId, UUID cardId) {
|
public DraftPickView sendCardMark(UUID draftId, UUID cardId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.sendCardMark(draftId, sessionId, cardId);
|
server.sendDraftCardMark(draftId, sessionId, cardId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1002,7 +1002,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean setBoosterLoaded(UUID draftId) {
|
public boolean setBoosterLoaded(UUID draftId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.setBoosterLoaded(draftId, sessionId);
|
server.draftSetBoosterLoaded(draftId, sessionId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1016,7 +1016,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean joinChat(UUID chatId) {
|
public boolean joinChat(UUID chatId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.joinChat(chatId, sessionId, connection.getUsername());
|
server.chatJoin(chatId, sessionId, connection.getUsername());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1032,7 +1032,7 @@ public class SessionImpl implements Session {
|
||||||
// lock.readLock().lock();
|
// lock.readLock().lock();
|
||||||
try {
|
try {
|
||||||
if (isConnected() && chatId != null) {
|
if (isConnected() && chatId != null) {
|
||||||
server.leaveChat(chatId, sessionId);
|
server.chatLeave(chatId, sessionId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1050,7 +1050,7 @@ public class SessionImpl implements Session {
|
||||||
// lock.readLock().lock();
|
// lock.readLock().lock();
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.sendChatMessage(chatId, connection.getUsername(), message);
|
server.chatSendMessage(chatId, connection.getUsername(), message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1067,7 +1067,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean sendBroadcastMessage(String message) {
|
public boolean sendBroadcastMessage(String message) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.sendBroadcastMessage(sessionId, message);
|
server.adminSendBroadcastMessage(sessionId, message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1082,7 +1082,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean joinGame(UUID gameId) {
|
public boolean joinGame(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.joinGame(gameId, sessionId);
|
server.gameJoin(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1097,7 +1097,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean joinDraft(UUID draftId) {
|
public boolean joinDraft(UUID draftId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.joinDraft(draftId, sessionId);
|
server.draftJoin(draftId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1112,7 +1112,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean joinTournament(UUID tournamentId) {
|
public boolean joinTournament(UUID tournamentId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.joinTournament(tournamentId, sessionId);
|
server.tournamentJoin(tournamentId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1127,7 +1127,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean watchGame(UUID gameId) {
|
public boolean watchGame(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.watchGame(gameId, sessionId);
|
return server.gameWatchStart(gameId, sessionId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1141,7 +1141,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean replayGame(UUID gameId) {
|
public boolean replayGame(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.replayGame(gameId, sessionId);
|
server.replayInit(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1156,7 +1156,7 @@ public class SessionImpl implements Session {
|
||||||
public TableView createTable(UUID roomId, MatchOptions matchOptions) {
|
public TableView createTable(UUID roomId, MatchOptions matchOptions) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.createTable(sessionId, roomId, matchOptions);
|
return server.roomCreateTable(sessionId, roomId, matchOptions);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1170,7 +1170,7 @@ public class SessionImpl implements Session {
|
||||||
public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) {
|
public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.createTournamentTable(sessionId, roomId, tournamentOptions);
|
return server.roomCreateTournament(sessionId, roomId, tournamentOptions);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1184,7 +1184,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean isTableOwner(UUID roomId, UUID tableId) {
|
public boolean isTableOwner(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.isTableOwner(sessionId, roomId, tableId);
|
return server.tableIsOwner(sessionId, roomId, tableId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1198,7 +1198,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean removeTable(UUID roomId, UUID tableId) {
|
public boolean removeTable(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.removeTable(sessionId, roomId, tableId);
|
server.tableRemove(sessionId, roomId, tableId);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1220,7 +1220,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean removeTable(UUID tableId) {
|
public boolean removeTable(UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.removeTable(sessionId, tableId);
|
server.adminTableRemove(sessionId, tableId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1235,7 +1235,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) {
|
public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.swapSeats(sessionId, roomId, tableId, seatNum1, seatNum2);
|
server.tableSwapSeats(sessionId, roomId, tableId, seatNum1, seatNum2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1249,7 +1249,7 @@ public class SessionImpl implements Session {
|
||||||
@Override
|
@Override
|
||||||
public boolean leaveTable(UUID roomId, UUID tableId) {
|
public boolean leaveTable(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected() && server.leaveTable(sessionId, roomId, tableId)) {
|
if (isConnected() && server.roomLeaveTableOrTournament(sessionId, roomId, tableId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1264,7 +1264,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean startMatch(UUID roomId, UUID tableId) {
|
public boolean startMatch(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return (server.startMatch(sessionId, roomId, tableId));
|
return (server.matchStart(sessionId, roomId, tableId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1275,7 +1275,7 @@ public class SessionImpl implements Session {
|
||||||
@Override
|
@Override
|
||||||
public boolean startTournament(UUID roomId, UUID tableId) {
|
public boolean startTournament(UUID roomId, UUID tableId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected() && server.startTournament(sessionId, roomId, tableId)) {
|
if (isConnected() && server.tournamentStart(sessionId, roomId, tableId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1309,7 +1309,7 @@ public class SessionImpl implements Session {
|
||||||
deck.setCardLayout(null);
|
deck.setCardLayout(null);
|
||||||
deck.setSideboardLayout(null);
|
deck.setSideboardLayout(null);
|
||||||
}
|
}
|
||||||
return server.submitDeck(sessionId, tableId, deck);
|
return server.deckSubmit(sessionId, tableId, deck);
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
handleGameException(ex);
|
handleGameException(ex);
|
||||||
|
|
@ -1329,7 +1329,7 @@ public class SessionImpl implements Session {
|
||||||
deck.setCardLayout(null);
|
deck.setCardLayout(null);
|
||||||
deck.setSideboardLayout(null);
|
deck.setSideboardLayout(null);
|
||||||
}
|
}
|
||||||
server.updateDeck(sessionId, tableId, deck);
|
server.deckSave(sessionId, tableId, deck);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
|
|
@ -1346,7 +1346,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean quitMatch(UUID gameId) {
|
public boolean quitMatch(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.quitMatch(gameId, sessionId);
|
server.matchQuit(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1361,7 +1361,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean quitTournament(UUID tournamentId) {
|
public boolean quitTournament(UUID tournamentId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.quitTournament(tournamentId, sessionId);
|
server.tournamentQuit(tournamentId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1376,7 +1376,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean quitDraft(UUID draftId) {
|
public boolean quitDraft(UUID draftId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.quitDraft(draftId, sessionId);
|
server.draftQuit(draftId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1409,7 +1409,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean stopWatching(UUID gameId) {
|
public boolean stopWatching(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.stopWatching(gameId, sessionId);
|
server.gameWatchStop(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1424,7 +1424,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean startReplay(UUID gameId) {
|
public boolean startReplay(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.startReplay(gameId, sessionId);
|
server.replayStart(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1439,7 +1439,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean stopReplay(UUID gameId) {
|
public boolean stopReplay(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.stopReplay(gameId, sessionId);
|
server.replayStop(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1454,7 +1454,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean nextPlay(UUID gameId) {
|
public boolean nextPlay(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.nextPlay(gameId, sessionId);
|
server.replayNext(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1469,7 +1469,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean previousPlay(UUID gameId) {
|
public boolean previousPlay(UUID gameId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.previousPlay(gameId, sessionId);
|
server.replayPrevious(gameId, sessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1484,7 +1484,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean skipForward(UUID gameId, int moves) {
|
public boolean skipForward(UUID gameId, int moves) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.skipForward(gameId, sessionId, moves);
|
server.replaySkipForward(gameId, sessionId, moves);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1499,7 +1499,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
|
public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.cheat(gameId, sessionId, playerId, deckList);
|
server.cheatMultiple(gameId, sessionId, playerId, deckList);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1514,7 +1514,7 @@ public class SessionImpl implements Session {
|
||||||
public List<UserView> getUsers() {
|
public List<UserView> getUsers() {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return server.getUsers(sessionId);
|
return server.adminGetUsers(sessionId);
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1528,7 +1528,7 @@ public class SessionImpl implements Session {
|
||||||
public List<String> getServerMessages() {
|
public List<String> getServerMessages() {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
return (List<String>) CompressUtil.decompress(server.getServerMessagesCompressed(sessionId));
|
return (List<String>) CompressUtil.decompress(server.serverGetPromotionMessages(sessionId));
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
|
|
@ -1539,10 +1539,10 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disconnectUser(String userSessionId) {
|
public boolean sendAdminDisconnectUser(String userSessionId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.disconnectUser(sessionId, userSessionId);
|
server.adminDisconnectUser(sessionId, userSessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1554,10 +1554,10 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean endUserSession(String userSessionId) {
|
public boolean sendAdminEndUserSession(String userSessionId) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.endUserSession(sessionId, userSessionId);
|
server.adminEndUserSession(sessionId, userSessionId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1569,10 +1569,10 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean muteUserChat(String userName, long durationMinutes) {
|
public boolean sendAdminMuteUserChat(String userName, long durationMinutes) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.muteUser(sessionId, userName, durationMinutes);
|
server.adminMuteUser(sessionId, userName, durationMinutes);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1584,10 +1584,10 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setActivation(String userName, boolean active) {
|
public boolean sendAdminActivateUser(String userName, boolean active) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.setActivation(sessionId, userName, active);
|
server.adminActivateUser(sessionId, userName, active);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1599,10 +1599,10 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean toggleActivation(String userName) {
|
public boolean sendAdminToggleActivateUser(String userName) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.toggleActivation(sessionId, userName);
|
server.adminToggleActivateUser(sessionId, userName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1614,10 +1614,10 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean lockUser(String userName, long durationMinute) {
|
public boolean sendAdminLockUser(String userName, long durationMinute) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.lockUser(sessionId, userName, durationMinute);
|
server.adminLockUser(sessionId, userName, durationMinute);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1679,7 +1679,7 @@ public class SessionImpl implements Session {
|
||||||
public boolean updatePreferencesForServer(UserData userData) {
|
public boolean updatePreferencesForServer(UserData userData) {
|
||||||
try {
|
try {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
server.setUserData(connection.getUsername(), sessionId, userData, null, null);
|
server.connectSetUserData(connection.getUsername(), sessionId, userData, null, null);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
|
|
@ -1718,7 +1718,7 @@ public class SessionImpl implements Session {
|
||||||
return true;
|
return true;
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
handleMageException(ex);
|
handleMageException(ex);
|
||||||
disconnect(true);
|
connectStop(true);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleThrowable(t);
|
handleThrowable(t);
|
||||||
}
|
}
|
||||||
|
|
@ -1752,7 +1752,6 @@ public class SessionImpl implements Session {
|
||||||
public String getLastError() {
|
public String getLastError() {
|
||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MageAuthenticator extends Authenticator {
|
class MageAuthenticator extends Authenticator {
|
||||||
|
|
|
||||||
|
|
@ -5,43 +5,45 @@ import mage.remote.Connection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Network: client side commands for a server
|
||||||
|
*
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public interface Connect {
|
public interface Connect {
|
||||||
|
|
||||||
boolean register(Connection connection);
|
String getSessionId();
|
||||||
|
|
||||||
boolean emailAuthToken(Connection connection);
|
String getLastError();
|
||||||
|
|
||||||
boolean resetPassword(Connection connection);
|
Optional<String> getServerHostname();
|
||||||
|
|
||||||
boolean connect(Connection connection);
|
boolean sendAuthRegister(Connection connection);
|
||||||
|
|
||||||
boolean stopConnecting();
|
boolean sendAuthSendTokenToEmail(Connection connection);
|
||||||
|
|
||||||
void disconnect(boolean showMessage);
|
boolean sendAuthResetPassword(Connection connection);
|
||||||
|
|
||||||
void reconnect(Throwable throwable);
|
boolean connectStart(Connection connection);
|
||||||
|
|
||||||
|
boolean connectAbort();
|
||||||
|
|
||||||
|
void connectStop(boolean showMessage);
|
||||||
|
|
||||||
|
void connectReconnect(Throwable throwable);
|
||||||
|
|
||||||
boolean ping();
|
boolean ping();
|
||||||
|
|
||||||
boolean isConnected();
|
boolean isConnected();
|
||||||
|
|
||||||
Optional<String> getServerHostname();
|
boolean sendAdminDisconnectUser(String userSessionId);
|
||||||
|
|
||||||
boolean disconnectUser(String userSessionId);
|
boolean sendAdminEndUserSession(String userSessionId);
|
||||||
|
|
||||||
boolean endUserSession(String userSessionId);
|
boolean sendAdminMuteUserChat(String userName, long durationMinute);
|
||||||
|
|
||||||
boolean muteUserChat(String userName, long durationMinute);
|
boolean sendAdminActivateUser(String userName, boolean active);
|
||||||
|
|
||||||
boolean setActivation(String userName, boolean active);
|
boolean sendAdminToggleActivateUser(String userName);
|
||||||
|
|
||||||
boolean toggleActivation(String userName);
|
boolean sendAdminLockUser(String userName, long durationMinute);
|
||||||
|
|
||||||
boolean lockUser(String userName, long durationMinute);
|
|
||||||
|
|
||||||
String getSessionId();
|
|
||||||
|
|
||||||
String getLastError();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(Connection connection) {
|
public boolean connect(Connection connection) {
|
||||||
if (session.connect(connection)) {
|
if (session.connectStart(connection)) {
|
||||||
this.consolePanel1.start();
|
this.consolePanel1.start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -157,7 +157,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
||||||
if (session.isConnected()) {
|
if (session.isConnected()) {
|
||||||
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
this.consolePanel1.stop();
|
this.consolePanel1.stop();
|
||||||
session.disconnect(false);
|
session.connectStop(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
connectDialog.showDialog(this);
|
connectDialog.showDialog(this);
|
||||||
|
|
@ -251,7 +251,7 @@ public class ConsoleFrame extends javax.swing.JFrame implements MageClient {
|
||||||
if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
|
if (JOptionPane.showConfirmDialog(this, "You are currently connected. Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session.disconnect(false);
|
session.connectStop(false);
|
||||||
} else {
|
} else {
|
||||||
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm exit", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
|
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Confirm exit", JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@
|
||||||
|
|
||||||
private void btnDisconnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDisconnectActionPerformed
|
private void btnDisconnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDisconnectActionPerformed
|
||||||
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
int row = this.tblUsers.convertRowIndexToModel(tblUsers.getSelectedRow());
|
||||||
ConsoleFrame.getSession().disconnectUser((String) tableUserModel.getValueAt(row, TableUserModel.POS_SESSION_ID));
|
ConsoleFrame.getSession().sendAdminDisconnectUser((String) tableUserModel.getValueAt(row, TableUserModel.POS_SESSION_ID));
|
||||||
}//GEN-LAST:event_btnDisconnectActionPerformed
|
}//GEN-LAST:event_btnDisconnectActionPerformed
|
||||||
|
|
||||||
private void btnEndSessionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEndSessionActionPerformed
|
private void btnEndSessionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEndSessionActionPerformed
|
||||||
|
|
@ -321,7 +321,7 @@
|
||||||
|
|
||||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to end userSessionId " + userSessionId + '?', "WARNING",
|
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to end userSessionId " + userSessionId + '?', "WARNING",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
ConsoleFrame.getSession().endUserSession(userSessionId);
|
ConsoleFrame.getSession().sendAdminEndUserSession(userSessionId);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnEndSessionActionPerformed
|
}//GEN-LAST:event_btnEndSessionActionPerformed
|
||||||
|
|
||||||
|
|
@ -331,7 +331,7 @@
|
||||||
long durationMinute = ((Number) spinnerMuteDurationMinutes.getValue()).longValue();
|
long durationMinute = ((Number) spinnerMuteDurationMinutes.getValue()).longValue();
|
||||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to mute user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to mute user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
ConsoleFrame.getSession().muteUserChat(userName, durationMinute);
|
ConsoleFrame.getSession().sendAdminMuteUserChat(userName, durationMinute);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnMuteUserActionPerformed
|
}//GEN-LAST:event_btnMuteUserActionPerformed
|
||||||
|
|
||||||
|
|
@ -346,17 +346,17 @@
|
||||||
|
|
||||||
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to active?", "WARNING",
|
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to active?", "WARNING",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
ConsoleFrame.getSession().setActivation(userName, true);
|
ConsoleFrame.getSession().sendAdminActivateUser(userName, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to inactive?", "WARNING",
|
if (JOptionPane.showConfirmDialog(null, "Did you want to set user: " + userName + " to inactive?", "WARNING",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
ConsoleFrame.getSession().setActivation(userName, false);
|
ConsoleFrame.getSession().sendAdminActivateUser(userName, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to toggle activation for user: " + userName + '?', "WARNING",
|
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to toggle activation for user: " + userName + '?', "WARNING",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
ConsoleFrame.getSession().toggleActivation(userName);
|
ConsoleFrame.getSession().sendAdminToggleActivateUser(userName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnDeActivateActionPerformed
|
}//GEN-LAST:event_btnDeActivateActionPerformed
|
||||||
|
|
@ -367,7 +367,7 @@
|
||||||
long durationMinute = ((Number) spinnerMuteDurationMinutes.getValue()).longValue();
|
long durationMinute = ((Number) spinnerMuteDurationMinutes.getValue()).longValue();
|
||||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to lock user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to lock user: " + userName + " for " + durationMinute + " minutes?", "WARNING",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
ConsoleFrame.getSession().lockUser(userName, durationMinute);
|
ConsoleFrame.getSession().sendAdminLockUser(userName, durationMinute);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_btnLockUserActionPerformed
|
}//GEN-LAST:event_btnLockUserActionPerformed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public enum DisconnectReason {
|
||||||
Disconnected(" has left XMage"),
|
Disconnected(" has left XMage"),
|
||||||
CleaningUp(" [cleaning up]"),
|
CleaningUp(" [cleaning up]"),
|
||||||
ConnectingOtherInstance(" reconnected and replaced still active old session"),
|
ConnectingOtherInstance(" reconnected and replaced still active old session"),
|
||||||
AdminDisconnect(" was disconnected by the Admin"),
|
AdminDisconnect(" was disconnected by the admin"),
|
||||||
SessionExpired(" session expired"),
|
SessionExpired(" session expired"),
|
||||||
Undefined("");
|
Undefined("");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerUser(String sessionId, String userName, String password, String email) throws MageException {
|
public boolean authRegister(String sessionId, String userName, String password, String email) throws MageException {
|
||||||
return managerFactory.sessionManager().registerUser(sessionId, userName, password, email);
|
return managerFactory.sessionManager().registerUser(sessionId, userName, password, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean emailAuthToken(String sessionId, String email) throws MageException {
|
public boolean authSendTokenToEmail(String sessionId, String email) throws MageException {
|
||||||
if (!managerFactory.configSettings().isAuthenticationActivated()) {
|
if (!managerFactory.configSettings().isAuthenticationActivated()) {
|
||||||
sendErrorMessageToClient(sessionId, Session.REGISTRATION_DISABLED_MESSAGE);
|
sendErrorMessageToClient(sessionId, Session.REGISTRATION_DISABLED_MESSAGE);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -113,7 +113,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resetPassword(String sessionId, String email, String authToken, String password) throws MageException {
|
public boolean authResetPassword(String sessionId, String email, String authToken, String password) throws MageException {
|
||||||
if (!managerFactory.configSettings().isAuthenticationActivated()) {
|
if (!managerFactory.configSettings().isAuthenticationActivated()) {
|
||||||
sendErrorMessageToClient(sessionId, Session.REGISTRATION_DISABLED_MESSAGE);
|
sendErrorMessageToClient(sessionId, Session.REGISTRATION_DISABLED_MESSAGE);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -162,7 +162,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setUserData(final String userName, final String sessionId, final UserData userData, final String clientVersion, final String userIdStr) throws MageException {
|
public boolean connectSetUserData(final String userName, final String sessionId, final UserData userData, final String clientVersion, final String userIdStr) throws MageException {
|
||||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -189,12 +189,12 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableView createTable(final String sessionId, final UUID roomId, final MatchOptions options) throws MageException {
|
public TableView roomCreateTable(final String sessionId, final UUID roomId, final MatchOptions options) throws MageException {
|
||||||
return executeWithResult("createTable", sessionId, new MyActionWithTableViewResult(sessionId, options, roomId));
|
return executeWithResult("createTable", sessionId, new CreateTableAction(sessionId, options, roomId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableView createTournamentTable(final String sessionId, final UUID roomId, final TournamentOptions options) throws MageException {
|
public TableView roomCreateTournament(final String sessionId, final UUID roomId, final TournamentOptions options) throws MageException {
|
||||||
return executeWithResult("createTournamentTable", sessionId, new ActionWithTableViewResult() {
|
return executeWithResult("createTournamentTable", sessionId, new ActionWithTableViewResult() {
|
||||||
@Override
|
@Override
|
||||||
public TableView execute() throws MageException {
|
public TableView execute() throws MageException {
|
||||||
|
|
@ -275,7 +275,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public void tableRemove(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
execute("removeTable", sessionId, () -> {
|
execute("removeTable", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -285,7 +285,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final PlayerType playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException {
|
public boolean roomJoinTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final PlayerType playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException {
|
||||||
return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("joinTable", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -310,7 +310,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final PlayerType playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException {
|
public boolean roomJoinTournament(final String sessionId, final UUID roomId, final UUID tableId, final String name, final PlayerType playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException {
|
||||||
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -338,8 +338,8 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean submitDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException {
|
public boolean deckSubmit(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException {
|
||||||
return executeWithResult("submitDeck", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("deckSubmit", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
|
|
@ -356,7 +356,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDeck(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException {
|
public void deckSave(final String sessionId, final UUID tableId, final DeckCardLists deckList) throws MageException {
|
||||||
execute("updateDeck", sessionId, () -> {
|
execute("updateDeck", sessionId, () -> {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
if (!session.isPresent()) {
|
if (!session.isPresent()) {
|
||||||
|
|
@ -372,7 +372,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<TableView> getTables(UUID roomId) throws MageException {
|
public List<TableView> roomGetAllTables(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
||||||
if (room.isPresent()) {
|
if (room.isPresent()) {
|
||||||
|
|
@ -388,7 +388,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
|
public List<MatchView> roomGetFinishedMatches(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return managerFactory.gamesRoomManager().getRoom(roomId).map(GamesRoom::getFinished).orElse(new ArrayList<>());
|
return managerFactory.gamesRoomManager().getRoom(roomId).map(GamesRoom::getFinished).orElse(new ArrayList<>());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -398,7 +398,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RoomUsersView> getRoomUsers(UUID roomId) throws MageException {
|
public List<RoomUsersView> roomGetUsers(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
||||||
if (room.isPresent()) {
|
if (room.isPresent()) {
|
||||||
|
|
@ -414,7 +414,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public TableView getTable(UUID roomId, UUID tableId) throws MageException {
|
public TableView roomGetTableById(UUID roomId, UUID tableId) throws MageException {
|
||||||
try {
|
try {
|
||||||
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
||||||
return room.flatMap(r -> r.getTable(tableId)).orElse(null);
|
return room.flatMap(r -> r.getTable(tableId)).orElse(null);
|
||||||
|
|
@ -431,7 +431,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean matchStart(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
Optional<TableController> controller = managerFactory.tableManager().getController(tableId);
|
Optional<TableController> controller = managerFactory.tableManager().getController(tableId);
|
||||||
if (!controller.isPresent()) {
|
if (!controller.isPresent()) {
|
||||||
logger.error("table not found : " + tableId);
|
logger.error("table not found : " + tableId);
|
||||||
|
|
@ -453,7 +453,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean tournamentStart(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
Optional<TableController> controller = managerFactory.tableManager().getController(tableId);
|
Optional<TableController> controller = managerFactory.tableManager().getController(tableId);
|
||||||
if (!controller.isPresent()) {
|
if (!controller.isPresent()) {
|
||||||
logger.error("table not found : " + tableId);
|
logger.error("table not found : " + tableId);
|
||||||
|
|
@ -476,7 +476,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public TournamentView getTournament(UUID tournamentId) throws MageException {
|
public TournamentView tournamentFindById(UUID tournamentId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return managerFactory.tournamentManager().getTournamentView(tournamentId);
|
return managerFactory.tournamentManager().getTournamentView(tournamentId);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -487,7 +487,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
public void chatSendMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
() -> managerFactory.chatManager().broadcast(chatId, userName, HtmlEscape.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null)
|
() -> managerFactory.chatManager().broadcast(chatId, userName, HtmlEscape.escapeHtml4(message), MessageColor.BLUE, true, null, ChatMessage.MessageType.TALK, null)
|
||||||
|
|
@ -498,7 +498,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinChat(final UUID chatId, final String sessionId, final String userName) throws MageException {
|
public void chatJoin(final UUID chatId, final String sessionId, final String userName) throws MageException {
|
||||||
execute("joinChat", sessionId, () -> {
|
execute("joinChat", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
|
|
||||||
|
|
@ -509,7 +509,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void leaveChat(final UUID chatId, final String sessionId) throws MageException {
|
public void chatLeave(final UUID chatId, final String sessionId) throws MageException {
|
||||||
execute("leaveChat", sessionId, () -> {
|
execute("leaveChat", sessionId, () -> {
|
||||||
if (chatId != null) {
|
if (chatId != null) {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
|
|
@ -522,7 +522,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getMainRoomId() throws MageException {
|
public UUID serverGetMainRoomId() throws MageException {
|
||||||
try {
|
try {
|
||||||
return managerFactory.gamesRoomManager().getMainRoomId();
|
return managerFactory.gamesRoomManager().getMainRoomId();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -533,7 +533,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getRoomChatId(UUID roomId) throws MageException {
|
public UUID chatFindByRoom(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
Optional<GamesRoom> room = managerFactory.gamesRoomManager().getRoom(roomId);
|
||||||
if (!room.isPresent()) {
|
if (!room.isPresent()) {
|
||||||
|
|
@ -548,7 +548,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTableOwner(final String sessionId, UUID roomId, final UUID tableId) throws MageException {
|
public boolean tableIsOwner(final String sessionId, UUID roomId, final UUID tableId) throws MageException {
|
||||||
return executeWithResult("isTableOwner", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("isTableOwner", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() {
|
public Boolean execute() {
|
||||||
|
|
@ -564,7 +564,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void swapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
|
public void tableSwapSeats(final String sessionId, final UUID roomId, final UUID tableId, final int seatNum1, final int seatNum2) throws MageException {
|
||||||
execute("swapSeats", sessionId, () -> {
|
execute("swapSeats", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -574,7 +574,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean roomLeaveTableOrTournament(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
Optional<TableController> tableController = managerFactory.tableManager().getController(tableId);
|
Optional<TableController> tableController = managerFactory.tableManager().getController(tableId);
|
||||||
if (tableController.isPresent()) {
|
if (tableController.isPresent()) {
|
||||||
TableState tableState = tableController.get().getTableState();
|
TableState tableState = tableController.get().getTableState();
|
||||||
|
|
@ -599,7 +599,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getTableChatId(UUID tableId) throws MageException {
|
public UUID chatFindByTable(UUID tableId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return managerFactory.tableManager().getChatId(tableId).orElse(null);
|
return managerFactory.tableManager().getChatId(tableId).orElse(null);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -609,7 +609,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinGame(final UUID gameId, final String sessionId) throws MageException {
|
public void gameJoin(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("joinGame", sessionId, () -> {
|
execute("joinGame", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -619,7 +619,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
|
public void draftJoin(final UUID draftId, final String sessionId) throws MageException {
|
||||||
execute("joinDraft", sessionId, () -> {
|
execute("joinDraft", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -629,7 +629,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void joinTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
public void tournamentJoin(final UUID tournamentId, final String sessionId) throws MageException {
|
||||||
execute("joinTournament", sessionId, () -> {
|
execute("joinTournament", sessionId, () -> {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
if (!session.isPresent()) {
|
if (!session.isPresent()) {
|
||||||
|
|
@ -643,7 +643,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getGameChatId(UUID gameId) throws MageException {
|
public UUID chatFindByGame(UUID gameId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return managerFactory.gameManager().getChatId(gameId).orElse(null);
|
return managerFactory.gameManager().getChatId(gameId).orElse(null);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -654,7 +654,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public UUID getTournamentChatId(UUID tournamentId) throws MageException {
|
public UUID chatFindByTournament(UUID tournamentId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return managerFactory.tournamentManager().getChatId(tournamentId).orElse(null);
|
return managerFactory.tournamentManager().getChatId(tournamentId).orElse(null);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
@ -724,12 +724,12 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DraftPickView sendCardPick(final UUID draftId, final String sessionId, final UUID cardPick, final Set<UUID> hiddenCards) throws MageException {
|
public DraftPickView sendDraftCardPick(final UUID draftId, final String sessionId, final UUID cardPick, final Set<UUID> hiddenCards) throws MageException {
|
||||||
return executeWithResult("sendCardPick", sessionId, new DraftPickViewActionWithNullNegativeResult(sessionId, draftId, cardPick, hiddenCards));
|
return executeWithResult("sendCardPick", sessionId, new SendCardPickAction(sessionId, draftId, cardPick, hiddenCards));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
|
public void sendDraftCardMark(final UUID draftId, final String sessionId, final UUID cardPick) throws MageException {
|
||||||
execute("sendCardMark", sessionId, () -> {
|
execute("sendCardMark", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -737,9 +737,9 @@ public class MageServerImpl implements MageServer {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBoosterLoaded(final UUID draftId, final String sessionId) throws MageException {
|
public void draftSetBoosterLoaded(final UUID draftId, final String sessionId) throws MageException {
|
||||||
execute("setBoosterLoaded", sessionId, () -> {
|
execute("setBoosterLoaded", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -749,7 +749,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void quitMatch(final UUID gameId, final String sessionId) throws MageException {
|
public void matchQuit(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("quitMatch", sessionId, () -> {
|
execute("quitMatch", sessionId, () -> {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
|
|
@ -767,7 +767,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void quitTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
public void tournamentQuit(final UUID tournamentId, final String sessionId) throws MageException {
|
||||||
execute("quitTournament", sessionId, () -> {
|
execute("quitTournament", sessionId, () -> {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
|
|
@ -787,7 +787,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
||||||
public void quitDraft(final UUID draftId, final String sessionId) throws MageException {
|
public void draftQuit(final UUID draftId, final String sessionId) throws MageException {
|
||||||
execute("quitDraft", sessionId, () -> {
|
execute("quitDraft", sessionId, () -> {
|
||||||
try {
|
try {
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
|
|
@ -822,7 +822,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean watchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean roomWatchTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -843,12 +843,12 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean watchTournamentTable(final String sessionId, final UUID tableId) throws MageException {
|
public boolean roomWatchTournament(final String sessionId, final UUID tableId) throws MageException {
|
||||||
return executeWithResult("setUserData", sessionId, new MyActionWithBooleanResult(sessionId, tableId));
|
return executeWithResult("setUserData", sessionId, new WatchTournamentTableAction(sessionId, tableId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean watchGame(final UUID gameId, final String sessionId) throws MageException {
|
public boolean gameWatchStart(final UUID gameId, final String sessionId) throws MageException {
|
||||||
return executeWithResult("watchGame", sessionId, new ActionWithResult<Boolean>() {
|
return executeWithResult("watchGame", sessionId, new ActionWithResult<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() throws MageException {
|
public Boolean execute() throws MageException {
|
||||||
|
|
@ -867,7 +867,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopWatching(final UUID gameId, final String sessionId) throws MageException {
|
public void gameWatchStop(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("stopWatching", sessionId, () -> {
|
execute("stopWatching", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -881,7 +881,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replayGame(final UUID gameId, final String sessionId) throws MageException {
|
public void replayInit(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("replayGame", sessionId, () -> {
|
execute("replayGame", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -891,7 +891,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startReplay(final UUID gameId, final String sessionId) throws MageException {
|
public void replayStart(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("startReplay", sessionId, () -> {
|
execute("startReplay", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
|
|
@ -901,7 +901,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopReplay(final UUID gameId, final String sessionId) throws MageException {
|
public void replayStop(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("stopReplay", sessionId, () -> {
|
execute("stopReplay", sessionId, () -> {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
if (!session.isPresent()) {
|
if (!session.isPresent()) {
|
||||||
|
|
@ -914,7 +914,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nextPlay(final UUID gameId, final String sessionId) throws MageException {
|
public void replayNext(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("nextPlay", sessionId, () -> {
|
execute("nextPlay", sessionId, () -> {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
if (!session.isPresent()) {
|
if (!session.isPresent()) {
|
||||||
|
|
@ -927,7 +927,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void previousPlay(final UUID gameId, final String sessionId) throws MageException {
|
public void replayPrevious(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("previousPlay", sessionId, () -> {
|
execute("previousPlay", sessionId, () -> {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
if (!session.isPresent()) {
|
if (!session.isPresent()) {
|
||||||
|
|
@ -940,7 +940,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void skipForward(final UUID gameId, final String sessionId, final int moves) throws MageException {
|
public void replaySkipForward(final UUID gameId, final String sessionId, final int moves) throws MageException {
|
||||||
execute("skipForward", sessionId, () -> {
|
execute("skipForward", sessionId, () -> {
|
||||||
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
Optional<Session> session = managerFactory.sessionManager().getSession(sessionId);
|
||||||
if (!session.isPresent()) {
|
if (!session.isPresent()) {
|
||||||
|
|
@ -954,7 +954,7 @@ public class MageServerImpl implements MageServer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//TODO: check how often it is used
|
//TODO: check how often it is used
|
||||||
public ServerState getServerState() throws MageException {
|
public ServerState serverGetState() throws MageException {
|
||||||
try {
|
try {
|
||||||
return new ServerState(
|
return new ServerState(
|
||||||
GameFactory.instance.getGameTypes(),
|
GameFactory.instance.getGameTypes(),
|
||||||
|
|
@ -974,7 +974,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cheat(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException {
|
public void cheatMultiple(final UUID gameId, final String sessionId, final UUID playerId, final DeckCardLists deckList) throws MageException {
|
||||||
execute("cheat", sessionId, () -> {
|
execute("cheat", sessionId, () -> {
|
||||||
if (testMode) {
|
if (testMode) {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
|
|
@ -986,7 +986,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cheat(final UUID gameId, final String sessionId, final UUID playerId, final String cardName) throws MageException {
|
public boolean cheatOne(final UUID gameId, final String sessionId, final UUID playerId, final String cardName) throws MageException {
|
||||||
return executeWithResult("cheatOne", sessionId, new ActionWithBooleanResult() {
|
return executeWithResult("cheatOne", sessionId, new ActionWithBooleanResult() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean execute() {
|
public Boolean execute() {
|
||||||
|
|
@ -1012,8 +1012,8 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameView getGameView(final UUID gameId, final String sessionId, final UUID playerId) throws MageException {
|
public GameView gameGetView(final UUID gameId, final String sessionId, final UUID playerId) throws MageException {
|
||||||
return executeWithResult("getGameView", sessionId, new GameViewActionWithNullNegativeResult(sessionId, gameId, playerId));
|
return executeWithResult("getGameView", sessionId, new GetGameViewAction(sessionId, gameId, playerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1024,30 +1024,32 @@ public class MageServerImpl implements MageServer {
|
||||||
* @throws MageException
|
* @throws MageException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<UserView> getUsers(String sessionId) throws MageException {
|
public List<UserView> adminGetUsers(String sessionId) throws MageException {
|
||||||
return executeWithResult("getUsers", sessionId, new ListActionWithNullNegativeResult(), true);
|
return executeWithResult("adminGetUsers", sessionId, new GetUsersAction(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnectUser(final String sessionId, final String userSessionId) throws MageException {
|
public void adminDisconnectUser(final String sessionId, final String userSessionId) throws MageException {
|
||||||
execute("disconnectUser", sessionId, () -> managerFactory.sessionManager().disconnectUser(sessionId, userSessionId));
|
execute("adminDisconnectUser", sessionId,
|
||||||
|
() -> managerFactory.sessionManager().disconnectUser(sessionId, userSessionId),
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void muteUser(final String sessionId, final String userName, final long durationMinutes) throws MageException {
|
public void adminMuteUser(final String sessionId, final String userName, final long durationMinutes) throws MageException {
|
||||||
execute("muteUser", sessionId, () -> {
|
execute("adminMuteUser", sessionId, () -> {
|
||||||
managerFactory.userManager().getUserByName(userName).ifPresent(user -> {
|
managerFactory.userManager().getUserByName(userName).ifPresent(user -> {
|
||||||
Date muteUntil = new Date(Calendar.getInstance().getTimeInMillis() + (durationMinutes * Timer.ONE_MINUTE));
|
Date muteUntil = new Date(Calendar.getInstance().getTimeInMillis() + (durationMinutes * Timer.ONE_MINUTE));
|
||||||
user.showUserMessage("Admin info", "You were muted for chat messages until " + SystemUtil.dateFormat.format(muteUntil) + '.');
|
user.showUserMessage("Admin info", "You were muted for chat messages until " + SystemUtil.dateFormat.format(muteUntil) + '.');
|
||||||
user.setChatLockedUntil(muteUntil);
|
user.setChatLockedUntil(muteUntil);
|
||||||
});
|
});
|
||||||
|
}, true);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lockUser(final String sessionId, final String userName, final long durationMinutes) throws MageException {
|
public void adminLockUser(final String sessionId, final String userName, final long durationMinutes) throws MageException {
|
||||||
execute("lockUser", sessionId, () -> {
|
execute("adminLockUser", sessionId, () -> {
|
||||||
managerFactory.userManager().getUserByName(userName).ifPresent(user -> {
|
managerFactory.userManager().getUserByName(userName).ifPresent(user -> {
|
||||||
Date lockUntil = new Date(Calendar.getInstance().getTimeInMillis() + (durationMinutes * Timer.ONE_MINUTE));
|
Date lockUntil = new Date(Calendar.getInstance().getTimeInMillis() + (durationMinutes * Timer.ONE_MINUTE));
|
||||||
user.showUserMessage("Admin info", "Your user profile was locked until " + SystemUtil.dateFormat.format(lockUntil) + '.');
|
user.showUserMessage("Admin info", "Your user profile was locked until " + SystemUtil.dateFormat.format(lockUntil) + '.');
|
||||||
|
|
@ -1056,13 +1058,12 @@ public class MageServerImpl implements MageServer {
|
||||||
managerFactory.sessionManager().disconnectUser(sessionId, user.getSessionId());
|
managerFactory.sessionManager().disconnectUser(sessionId, user.getSessionId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}, true);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setActivation(final String sessionId, final String userName, boolean active) throws MageException {
|
public void adminActivateUser(final String sessionId, final String userName, boolean active) throws MageException {
|
||||||
execute("setActivation", sessionId, () -> {
|
execute("adminActivateUser", sessionId, () -> {
|
||||||
AuthorizedUser authorizedUser = AuthorizedUserRepository.getInstance().getByName(userName);
|
AuthorizedUser authorizedUser = AuthorizedUserRepository.getInstance().getByName(userName);
|
||||||
Optional<User> u = managerFactory.userManager().getUserByName(userName);
|
Optional<User> u = managerFactory.userManager().getUserByName(userName);
|
||||||
if (u.isPresent()) {
|
if (u.isPresent()) {
|
||||||
|
|
@ -1075,25 +1076,25 @@ public class MageServerImpl implements MageServer {
|
||||||
User theUser = new User(managerFactory, userName, "localhost", authorizedUser);
|
User theUser = new User(managerFactory, userName, "localhost", authorizedUser);
|
||||||
theUser.setActive(active);
|
theUser.setActive(active);
|
||||||
}
|
}
|
||||||
|
}, true);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toggleActivation(final String sessionId, final String userName) throws MageException {
|
public void adminToggleActivateUser(final String sessionId, final String userName) throws MageException {
|
||||||
execute("toggleActivation", sessionId, ()
|
execute("adminToggleActivateUser", sessionId, () -> managerFactory.userManager().getUserByName(userName).ifPresent(user -> {
|
||||||
-> managerFactory.userManager().getUserByName(userName).ifPresent(user
|
|
||||||
-> {
|
|
||||||
user.setActive(!user.isActive());
|
user.setActive(!user.isActive());
|
||||||
if (!user.isActive() && user.isConnected()) {
|
if (!user.isActive() && user.isConnected()) {
|
||||||
managerFactory.sessionManager().disconnectUser(sessionId, user.getSessionId());
|
managerFactory.sessionManager().disconnectUser(sessionId, user.getSessionId());
|
||||||
}
|
}
|
||||||
}));
|
}), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endUserSession(final String sessionId, final String userSessionId) throws MageException {
|
public void adminEndUserSession(final String sessionId, final String userSessionId) throws MageException {
|
||||||
execute("endUserSession", sessionId, () -> managerFactory.sessionManager().endUserSession(sessionId, userSessionId));
|
execute("adminEndUserSession", sessionId,
|
||||||
|
() -> managerFactory.sessionManager().endUserSession(sessionId, userSessionId),
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1104,22 +1105,22 @@ public class MageServerImpl implements MageServer {
|
||||||
* @throws MageException
|
* @throws MageException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeTable(final String sessionId, final UUID tableId) throws MageException {
|
public void adminTableRemove(final String sessionId, final UUID tableId) throws MageException {
|
||||||
execute("removeTable", sessionId, () -> {
|
execute("adminTableRemove", sessionId, () -> {
|
||||||
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
managerFactory.sessionManager().getSession(sessionId).ifPresent(session -> {
|
||||||
UUID userId = session.getUserId();
|
UUID userId = session.getUserId();
|
||||||
managerFactory.tableManager().removeTable(userId, tableId);
|
managerFactory.tableManager().removeTable(userId, tableId);
|
||||||
});
|
});
|
||||||
});
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getServerMessagesCompressed(String sessionId) throws MageException {
|
public Object serverGetPromotionMessages(String sessionId) throws MageException {
|
||||||
return executeWithResult("getGameView", sessionId, new MyActionWithNullNegativeResult());
|
return executeWithResult("serverGetPromotionMessages", sessionId, new GetPromotionMessagesAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
|
public void serverAddFeedbackMessage(final String sessionId, final String username, final String title, final String type, final String message, final String email) throws MageException {
|
||||||
if (title != null && message != null) {
|
if (title != null && message != null) {
|
||||||
execute("sendFeedbackMessage", sessionId, ()
|
execute("sendFeedbackMessage", sessionId, ()
|
||||||
-> managerFactory.sessionManager().getSession(sessionId).ifPresent(
|
-> managerFactory.sessionManager().getSession(sessionId).ifPresent(
|
||||||
|
|
@ -1129,7 +1130,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendBroadcastMessage(final String sessionId, final String message) throws MageException {
|
public void adminSendBroadcastMessage(final String sessionId, final String message) throws MageException {
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
execute("sendBroadcastMessage", sessionId, () -> {
|
execute("sendBroadcastMessage", sessionId, () -> {
|
||||||
for (User user : managerFactory.userManager().getUsers()) {
|
for (User user : managerFactory.userManager().getUsers()) {
|
||||||
|
|
@ -1148,10 +1149,8 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void execute(final String actionName, final String sessionId, final Action action, boolean checkAdminRights) throws MageException {
|
protected void execute(final String actionName, final String sessionId, final Action action, boolean checkAdminRights) throws MageException {
|
||||||
if (checkAdminRights) {
|
if (checkAdminRights && !managerFactory.sessionManager().checkAdminAccess(sessionId)) {
|
||||||
if (!managerFactory.sessionManager().isAdmin(sessionId)) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
execute(actionName, sessionId, action);
|
execute(actionName, sessionId, action);
|
||||||
}
|
}
|
||||||
|
|
@ -1177,10 +1176,8 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T executeWithResult(String actionName, final String sessionId, final ActionWithResult<T> action, boolean checkAdminRights) throws MageException {
|
protected <T> T executeWithResult(String actionName, final String sessionId, final ActionWithResult<T> action, boolean checkAdminRights) throws MageException {
|
||||||
if (checkAdminRights) {
|
if (checkAdminRights && !managerFactory.sessionManager().checkAdminAccess(sessionId)) {
|
||||||
if (!managerFactory.sessionManager().isAdmin(sessionId)) {
|
return action.negativeResult();
|
||||||
return action.negativeResult();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return executeWithResult(actionName, sessionId, action);
|
return executeWithResult(actionName, sessionId, action);
|
||||||
}
|
}
|
||||||
|
|
@ -1198,7 +1195,7 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ExpansionInfo> getMissingExpansionData(List<String> codes) {
|
public List<ExpansionInfo> syncGetMissingExpansionData(List<String> codes) {
|
||||||
List<ExpansionInfo> result = new ArrayList<>();
|
List<ExpansionInfo> result = new ArrayList<>();
|
||||||
for (ExpansionInfo expansionInfo : ExpansionRepository.instance.getAll()) {
|
for (ExpansionInfo expansionInfo : ExpansionRepository.instance.getAll()) {
|
||||||
if (!codes.contains(expansionInfo.getCode())) {
|
if (!codes.contains(expansionInfo.getCode())) {
|
||||||
|
|
@ -1210,21 +1207,20 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CardInfo> getMissingCardsData(List<String> classNames) {
|
public List<CardInfo> syncGetMissingCardsData(List<String> classNames) {
|
||||||
List<CardInfo> res = CardRepository.instance.getMissingCards(classNames);
|
List<CardInfo> res = CardRepository.instance.getMissingCards(classNames);
|
||||||
logger.info("Missing cards downloaded: " + res.size());
|
logger.info("Missing cards downloaded: " + res.size());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MyActionWithNullNegativeResult extends ActionWithNullNegativeResult<Object> {
|
private static class GetPromotionMessagesAction extends ActionWithNullNegativeResult<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute() throws MageException {
|
public Object execute() throws MageException {
|
||||||
return CompressUtil.compress(ServerMessagesUtil.instance.getMessages());
|
return CompressUtil.compress(ServerMessagesUtil.instance.getMessages());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ListActionWithNullNegativeResult extends ActionWithNullNegativeResult<List<UserView>> {
|
private class GetUsersAction extends ActionWithNullNegativeResult<List<UserView>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserView> execute() throws MageException {
|
public List<UserView> execute() throws MageException {
|
||||||
|
|
@ -1232,13 +1228,13 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class GameViewActionWithNullNegativeResult extends ActionWithNullNegativeResult<GameView> {
|
private class GetGameViewAction extends ActionWithNullNegativeResult<GameView> {
|
||||||
|
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
private final UUID gameId;
|
private final UUID gameId;
|
||||||
private final UUID playerId;
|
private final UUID playerId;
|
||||||
|
|
||||||
public GameViewActionWithNullNegativeResult(String sessionId, UUID gameId, UUID playerId) {
|
public GetGameViewAction(String sessionId, UUID gameId, UUID playerId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
|
|
@ -1257,12 +1253,12 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyActionWithBooleanResult extends ActionWithBooleanResult {
|
private class WatchTournamentTableAction extends ActionWithBooleanResult {
|
||||||
|
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
private final UUID tableId;
|
private final UUID tableId;
|
||||||
|
|
||||||
public MyActionWithBooleanResult(String sessionId, UUID tableId) {
|
public WatchTournamentTableAction(String sessionId, UUID tableId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
}
|
}
|
||||||
|
|
@ -1279,14 +1275,14 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DraftPickViewActionWithNullNegativeResult extends ActionWithNullNegativeResult<DraftPickView> {
|
private class SendCardPickAction extends ActionWithNullNegativeResult<DraftPickView> {
|
||||||
|
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
private final UUID draftId;
|
private final UUID draftId;
|
||||||
private final UUID cardPick;
|
private final UUID cardPick;
|
||||||
private final Set<UUID> hiddenCards;
|
private final Set<UUID> hiddenCards;
|
||||||
|
|
||||||
public DraftPickViewActionWithNullNegativeResult(String sessionId, UUID draftId, UUID cardPick, Set<UUID> hiddenCards) {
|
public SendCardPickAction(String sessionId, UUID draftId, UUID cardPick, Set<UUID> hiddenCards) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.draftId = draftId;
|
this.draftId = draftId;
|
||||||
this.cardPick = cardPick;
|
this.cardPick = cardPick;
|
||||||
|
|
@ -1305,13 +1301,13 @@ public class MageServerImpl implements MageServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyActionWithTableViewResult extends ActionWithTableViewResult {
|
private class CreateTableAction extends ActionWithTableViewResult {
|
||||||
|
|
||||||
private final String sessionId;
|
private final String sessionId;
|
||||||
private final MatchOptions options;
|
private final MatchOptions options;
|
||||||
private final UUID roomId;
|
private final UUID roomId;
|
||||||
|
|
||||||
public MyActionWithTableViewResult(String sessionId, MatchOptions options, UUID roomId) {
|
public CreateTableAction(String sessionId, MatchOptions options, UUID roomId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ public final class Main {
|
||||||
try {
|
try {
|
||||||
MageServer testServer = (MageServer) TransporterClient.createTransporterClient(serverLocator.getLocatorURI(), MageServer.class, metadata);
|
MageServer testServer = (MageServer) TransporterClient.createTransporterClient(serverLocator.getLocatorURI(), MageServer.class, metadata);
|
||||||
if (testServer != null) {
|
if (testServer != null) {
|
||||||
testServer.getServerState();
|
testServer.serverGetState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class SessionManagerImpl implements SessionManager {
|
||||||
Session session = sessions.get(sessionId);
|
Session session = sessions.get(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.connectAdmin();
|
session.connectAdmin();
|
||||||
logger.info("Admin connected from " + session.getHost());
|
logger.warn("Admin connected from " + session.getHost());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -155,19 +155,20 @@ public class SessionManagerImpl implements SessionManager {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void disconnectUser(String sessionId, String userSessionId) {
|
public void disconnectUser(String sessionId, String userSessionId) {
|
||||||
if (isAdmin(sessionId)) {
|
if (!checkAdminAccess(sessionId)) {
|
||||||
getUserFromSession(sessionId).ifPresent(admin -> {
|
return;
|
||||||
Optional<User> u = getUserFromSession(userSessionId);
|
|
||||||
if (u.isPresent()) {
|
|
||||||
User user = u.get();
|
|
||||||
user.showUserMessage("Admin operation", "Your session was disconnected by Admin.");
|
|
||||||
admin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
|
|
||||||
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
|
||||||
} else {
|
|
||||||
admin.showUserMessage("Admin operation", "User with sessionId " + userSessionId + " could not be found!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
getUserFromSession(sessionId).ifPresent(admin -> {
|
||||||
|
Optional<User> u = getUserFromSession(userSessionId);
|
||||||
|
if (u.isPresent()) {
|
||||||
|
User user = u.get();
|
||||||
|
user.showUserMessage("Admin action", "Your session was disconnected by admin");
|
||||||
|
admin.showUserMessage("Admin result", "User " + user.getName() + " was disconnected");
|
||||||
|
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
||||||
|
} else {
|
||||||
|
admin.showUserMessage("Admin result", "User with sessionId " + userSessionId + " could not be found");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<User> getUserFromSession(String sessionId) {
|
private Optional<User> getUserFromSession(String sessionId) {
|
||||||
|
|
@ -178,15 +179,27 @@ public class SessionManagerImpl implements SessionManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endUserSession(String sessionId, String userSessionId) {
|
public void endUserSession(String sessionId, String userSessionId) {
|
||||||
if (isAdmin(sessionId)) {
|
if (!checkAdminAccess(sessionId)) {
|
||||||
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnect(userSessionId, DisconnectReason.AdminDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAdmin(String sessionId) {
|
public boolean checkAdminAccess(String sessionId) {
|
||||||
return getSession(sessionId).map(Session::isAdmin).orElse(false);
|
Session session = sessions.get(sessionId);
|
||||||
|
if (session == null) {
|
||||||
|
logger.error("Wrong admin access with unknown session: " + sessionId, new Throwable());
|
||||||
|
} else if (!session.isAdmin()) {
|
||||||
|
String info = String.format("sessionId %s for userId %s at %s",
|
||||||
|
session.getId(),
|
||||||
|
session.getUserId(),
|
||||||
|
session.getHost()
|
||||||
|
);
|
||||||
|
logger.error("Wrong admin access with user session: " + info, new Throwable());
|
||||||
|
}
|
||||||
|
return session != null && session.isAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -271,9 +271,9 @@ public class User {
|
||||||
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_TOURNAMENT, tournamentId));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_TOURNAMENT, tournamentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showUserMessage(final String titel, String message) {
|
public void showUserMessage(final String title, String message) {
|
||||||
List<String> messageData = new LinkedList<>();
|
List<String> messageData = new LinkedList<>();
|
||||||
messageData.add(titel);
|
messageData.add(title);
|
||||||
messageData.add(message);
|
messageData.add(message);
|
||||||
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
fireCallback(new ClientCallback(ClientCallbackMethod.SHOW_USERMESSAGE, null, messageData));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class DraftController {
|
||||||
(Listener<PlayerQueryEvent>) event -> {
|
(Listener<PlayerQueryEvent>) event -> {
|
||||||
try {
|
try {
|
||||||
switch (event.getQueryType()) {
|
switch (event.getQueryType()) {
|
||||||
case PICK_CARD:
|
case DRAFT_PICK_CARD:
|
||||||
pickCard(event.getPlayerId(), event.getMax());
|
pickCard(event.getPlayerId(), event.getMax());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,12 @@ public class GameController implements GameCallback {
|
||||||
case PERSONAL_MESSAGE:
|
case PERSONAL_MESSAGE:
|
||||||
informPersonal(event.getPlayerId(), event.getMessage());
|
informPersonal(event.getPlayerId(), event.getMessage());
|
||||||
break;
|
break;
|
||||||
|
case TOURNAMENT_CONSTRUCT:
|
||||||
|
case DRAFT_PICK_CARD:
|
||||||
|
// tournament and draft events, impossible to catch it here
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown game event: " + event.getQueryType());
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
logger.fatal("Player event listener error ", ex);
|
logger.fatal("Player event listener error ", ex);
|
||||||
|
|
@ -771,15 +777,14 @@ public class GameController implements GameCallback {
|
||||||
|
|
||||||
public void sendPlayerBoolean(UUID userId, final Boolean data) {
|
public void sendPlayerBoolean(UUID userId, final Boolean data) {
|
||||||
sendMessage(userId, playerId -> getGameSession(playerId).sendPlayerBoolean(data));
|
sendMessage(userId, playerId -> getGameSession(playerId).sendPlayerBoolean(data));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerInteger(UUID userId, final Integer data) {
|
public void sendPlayerInteger(UUID userId, final Integer data) {
|
||||||
sendMessage(userId, playerId -> getGameSession(playerId).sendPlayerInteger(data));
|
sendMessage(userId, playerId -> getGameSession(playerId).sendPlayerInteger(data));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void updateGame() {
|
private void updatePriorityTimers() {
|
||||||
|
// update player timers to actual values
|
||||||
if (!timers.isEmpty()) {
|
if (!timers.isEmpty()) {
|
||||||
for (Player player : game.getState().getPlayers().values()) {
|
for (Player player : game.getState().getPlayers().values()) {
|
||||||
PriorityTimer timer = timers.get(player.getId());
|
PriorityTimer timer = timers.get(player.getId());
|
||||||
|
|
@ -788,6 +793,10 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void updateGame() {
|
||||||
|
updatePriorityTimers();
|
||||||
for (final GameSessionPlayer gameSession : getGameSessions()) {
|
for (final GameSessionPlayer gameSession : getGameSessions()) {
|
||||||
gameSession.update();
|
gameSession.update();
|
||||||
}
|
}
|
||||||
|
|
@ -941,7 +950,7 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameView getGameView(UUID playerId) {
|
public synchronized GameView getGameView(UUID playerId) {
|
||||||
return getGameSession(playerId).getGameView();
|
return getGameSession(playerId).getGameView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1116,14 +1125,13 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameSessionPlayer getGameSession(UUID playerId) {
|
private GameSessionPlayer getGameSession(UUID playerId) {
|
||||||
if (!timers.isEmpty()) {
|
// TODO: check parent callers - there are possible problems with sync, can be related to broken "fix" logs too
|
||||||
Player player = game.getState().getPlayer(playerId);
|
// It modify players data, but:
|
||||||
PriorityTimer timer = timers.get(playerId);
|
// * some sendXXX methods calls without synchronized (getGameSession can be in read mode?)
|
||||||
if (timer != null) {
|
// * some informXXX methods calls with synchronized (users must get actual data, so keep write mode and add synchronized?)
|
||||||
//logger.warn("Timer Player " + player.getName()+ " " + player.getPriorityTimeLeft() + " Timer: " + timer.getCount());
|
// find actual timers before send data
|
||||||
player.setPriorityTimeLeft(timer.getCount());
|
updatePriorityTimers();
|
||||||
}
|
|
||||||
}
|
|
||||||
return gameSessions.get(playerId);
|
return gameSessions.get(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import javax.annotation.Nonnull;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface SessionManager {
|
public interface SessionManager {
|
||||||
|
|
||||||
Optional<Session> getSession(@Nonnull String sessionId);
|
Optional<Session> getSession(@Nonnull String sessionId);
|
||||||
|
|
||||||
void createSession(String sessionId, InvokerCallbackHandler callbackHandler);
|
void createSession(String sessionId, InvokerCallbackHandler callbackHandler);
|
||||||
|
|
@ -31,7 +32,7 @@ public interface SessionManager {
|
||||||
|
|
||||||
void endUserSession(String sessionId, String userSessionId);
|
void endUserSession(String sessionId, String userSessionId);
|
||||||
|
|
||||||
boolean isAdmin(String sessionId);
|
boolean checkAdminAccess(String sessionId);
|
||||||
|
|
||||||
boolean isValidSession(@Nonnull String sessionId);
|
boolean isValidSession(@Nonnull String sessionId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ public class TournamentController {
|
||||||
(Listener<PlayerQueryEvent>) event -> {
|
(Listener<PlayerQueryEvent>) event -> {
|
||||||
try {
|
try {
|
||||||
switch (event.getQueryType()) {
|
switch (event.getQueryType()) {
|
||||||
case CONSTRUCT:
|
case TOURNAMENT_CONSTRUCT:
|
||||||
construct(event.getPlayerId(), event.getMax());
|
construct(event.getPlayerId(), event.getMax());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -548,7 +548,7 @@ public class LoadTest {
|
||||||
this.client = new SimpleMageClient(joinGameChat, logsPrefix, TEST_SHOW_GAME_LOGS_AS_HTML);
|
this.client = new SimpleMageClient(joinGameChat, logsPrefix, TEST_SHOW_GAME_LOGS_AS_HTML);
|
||||||
this.session = new SessionImpl(this.client);
|
this.session = new SessionImpl(this.client);
|
||||||
|
|
||||||
this.session.connect(this.connection);
|
this.session.connectStart(this.connection);
|
||||||
this.client.setSession(this.session);
|
this.client.setSession(this.session);
|
||||||
this.roomID = this.session.getMainRoomId();
|
this.roomID = this.session.getMainRoomId();
|
||||||
|
|
||||||
|
|
@ -607,7 +607,7 @@ public class LoadTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
this.session.disconnect(false);
|
this.session.connectStop(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void concede() {
|
public void concede() {
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
PLAY_X_MANA,
|
PLAY_X_MANA,
|
||||||
AMOUNT,
|
AMOUNT,
|
||||||
MULTI_AMOUNT,
|
MULTI_AMOUNT,
|
||||||
PICK_CARD,
|
DRAFT_PICK_CARD,
|
||||||
CONSTRUCT,
|
TOURNAMENT_CONSTRUCT,
|
||||||
CHOOSE_PILE,
|
CHOOSE_PILE,
|
||||||
PERSONAL_MESSAGE
|
PERSONAL_MESSAGE
|
||||||
}
|
}
|
||||||
|
|
@ -224,11 +224,11 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerQueryEvent pickCard(UUID playerId, String message, List<Card> booster, int time) {
|
public static PlayerQueryEvent pickCard(UUID playerId, String message, List<Card> booster, int time) {
|
||||||
return new PlayerQueryEvent(playerId, message, booster, QueryType.PICK_CARD, time);
|
return new PlayerQueryEvent(playerId, message, booster, QueryType.DRAFT_PICK_CARD, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerQueryEvent construct(UUID playerId, String message, int time) {
|
public static PlayerQueryEvent construct(UUID playerId, String message, int time) {
|
||||||
return new PlayerQueryEvent(playerId, message, QueryType.CONSTRUCT, time);
|
return new PlayerQueryEvent(playerId, message, QueryType.TOURNAMENT_CONSTRUCT, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerQueryEvent informPersonal(UUID playerId, String message) {
|
public static PlayerQueryEvent informPersonal(UUID playerId, String message) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue