diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 75bde3d85ec..702a8f45f64 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -80,8 +80,8 @@ import mage.client.tournament.TournamentPane; import mage.game.match.MatchOptions; import mage.utils.MageVersion; import mage.sets.Sets; -import mage.utils.Connection; -import mage.utils.Connection.ProxyType; +import mage.remote.Connection; +import mage.remote.Connection.ProxyType; import mage.view.TableView; import org.apache.log4j.Logger; diff --git a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java index a0941448d3a..985d8a29ee2 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/ConnectDialog.java @@ -52,8 +52,8 @@ import javax.swing.event.ListSelectionListener; import mage.client.MageFrame; import mage.client.util.Config; -import mage.utils.Connection; -import mage.utils.Connection.ProxyType; +import mage.remote.Connection; +import mage.remote.Connection.ProxyType; import org.apache.log4j.Logger; diff --git a/Mage.Client/src/main/java/mage/client/remote/Client.java b/Mage.Client/src/main/java/mage/client/remote/Client.java index b62f5d7f240..4fb8ccbf37f 100644 --- a/Mage.Client/src/main/java/mage/client/remote/Client.java +++ b/Mage.Client/src/main/java/mage/client/remote/Client.java @@ -126,7 +126,7 @@ public class Client implements CallbackClient { GamePanel panel = session.getGame(callback.getObjectId()); if (panel != null) { panel.init((GameView) callback.getData()); - session.ack("gameInit"); + } } else if (callback.getMethod().equals("gameOver")) { @@ -233,10 +233,10 @@ public class Client implements CallbackClient { } } else if (callback.getMethod().equals("draftInit")) { - session.ack("draftInit"); + } else if (callback.getMethod().equals("tournamentInit")) { - session.ack("tournamentInit"); + } messageId = callback.getMessageId(); } diff --git a/Mage.Client/src/main/java/mage/client/remote/Session.java b/Mage.Client/src/main/java/mage/client/remote/Session.java index acbb0bebde8..0739bab49ae 100644 --- a/Mage.Client/src/main/java/mage/client/remote/Session.java +++ b/Mage.Client/src/main/java/mage/client/remote/Session.java @@ -30,7 +30,6 @@ package mage.client.remote; import java.net.Authenticator; import java.net.PasswordAuthentication; -import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; @@ -43,25 +42,25 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import javax.swing.JLayeredPane; import javax.swing.JOptionPane; import mage.cards.decks.DeckCardLists; import mage.client.MageFrame; import mage.client.chat.ChatPanel; import mage.client.components.MageUI; -import mage.client.dialog.ReconnectDialog; import mage.client.draft.DraftPanel; import mage.client.game.GamePanel; +import mage.remote.method.*; import mage.client.tournament.TournamentPanel; -import mage.client.util.Config; import mage.game.GameException; -import mage.interfaces.MageException; +import mage.MageException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; -import mage.interfaces.Server; import mage.interfaces.ServerState; import mage.interfaces.callback.CallbackClientDaemon; -import mage.utils.Connection; +import mage.remote.Connection; +import mage.remote.ServerCache; +import mage.remote.ServerUnavailable; +import mage.utils.MageVersion; import mage.view.DraftPickView; import mage.view.GameTypeView; import mage.view.TableView; @@ -79,7 +78,6 @@ public class Session { private static ScheduledExecutorService sessionExecutor = Executors.newScheduledThreadPool(1); private UUID sessionId; - private Server server; private Client client; private String userName; private MageFrame frame; @@ -101,7 +99,7 @@ public class Session { public synchronized boolean connect(Connection connection) { this.connecting = true; - if (isConnected()) { + if (this.connection != null && isConnected()) { disconnect(true); } this.connection = connection; @@ -132,13 +130,12 @@ public class Session { break; } Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort()); - this.server = (Server) reg.lookup(Config.remoteServer); this.userName = connection.getUsername(); if (client == null) client = new Client(this, frame); - sessionId = server.registerClient(userName, client.getId(), frame.getVersion()); - callbackDaemon = new CallbackClientDaemon(sessionId, client, server); - serverState = server.getServerState(); + sessionId = registerClient(userName, client.getId(), frame.getVersion()); + callbackDaemon = new CallbackClientDaemon(sessionId, client, connection); + serverState = getServerState(); future = sessionExecutor.scheduleWithFixedDelay(new ServerPinger(), 5, 5, TimeUnit.SECONDS); logger.info("Connected to RMI server at " + connection.getHost() + ":" + connection.getPort()); frame.setStatusText("Connected to " + connection.getHost() + ":" + connection.getPort() + " "); @@ -158,8 +155,6 @@ public class Session { disconnect(false); JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage()); } - } catch (NotBoundException ex) { - logger.fatal("Unable to connect to server - ", ex); } return false; } @@ -171,28 +166,26 @@ public class Session { future.cancel(true); frame.setStatusText("Not connected"); frame.disableButtons(); - server = null; - if (!voluntary && !connecting) { - if (attemptReconnect()) - return; - } +// if (!voluntary && !connecting) { +// if (attemptReconnect()) +// return; +// } try { for (UUID chatId: chats.keySet()) { - server.leaveChat(chatId, sessionId); + leaveChat(chatId); } } - catch (Exception ex) { + catch (Exception ignore) { //swallow all exceptions at this point } try { - //TODO: stop daemon - if (server != null) - server.deregisterClient(sessionId); - } catch (RemoteException ex) { - logger.fatal("Error disconnecting ...", ex); + if (callbackDaemon != null) + callbackDaemon.stopDaemon(); + deregisterClient(); } catch (MageException ex) { logger.fatal("Error disconnecting ...", ex); } + ServerCache.removeServerFromCache(connection); frame.hideGames(); frame.hideTables(); logger.info("Disconnected ... "); @@ -200,38 +193,61 @@ public class Session { JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Server error. You have been disconnected", "Error", JOptionPane.ERROR_MESSAGE); } - private boolean attemptReconnect() { - reconnecting = true; - ReconnectDialog rcd = new ReconnectDialog(); - MageFrame.getDesktop().add(rcd, JLayeredPane.MODAL_LAYER); - rcd.showDialog(this); - reconnecting = false; - return rcd.getResult(); - } +// private boolean attemptReconnect() { +// reconnecting = true; +// ReconnectDialog rcd = new ReconnectDialog(); +// MageFrame.getDesktop().add(rcd, JLayeredPane.MODAL_LAYER); +// rcd.showDialog(this); +// reconnecting = false; +// return rcd.getResult(); +// } - public void ack(String message) { - try { - server.ack(message, sessionId); - } catch (RemoteException ex) { - handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); - } - } - public boolean ping() { + Ping method = new Ping(connection, sessionId); try { - return server.ping(sessionId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + logger.fatal("server unavailable - ", ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("ping error", ex); } return false; } - + + + private UUID registerClient(String userName, UUID clientId, MageVersion version) throws MageException { + RegisterClient method = new RegisterClient(connection, userName, clientId, version); + try { + return method.makeCall(); + } catch (ServerUnavailable ex) { + logger.fatal("server unavailable - ", ex); + } + return null; + } + + private void deregisterClient() throws MageException { + DeregisterClient method = new DeregisterClient(connection, sessionId); + try { + method.makeCall(); + } catch (ServerUnavailable ex) { + logger.fatal("server unavailable - ", ex); + } + } + + private ServerState getServerState() { + GetServerState method = new GetServerState(connection); + try { + return method.makeCall(); + } catch (ServerUnavailable ex) { + logger.fatal("server unavailable - ", ex); + } catch (MageException ex) { + logger.fatal("GetServerState error", ex); + } + return null; + } + public boolean isConnected() { - return server != null; + return ping(); } public String[] getPlayerTypes() { @@ -281,514 +297,557 @@ public class Session { } public UUID getMainRoomId() { + GetMainRoomId method = new GetMainRoomId(connection); try { - return server.getMainRoomId(); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("GetMainRoomId error", ex); } return null; } public UUID getRoomChatId(UUID roomId) { + GetRoomChatId method = new GetRoomChatId(connection, roomId); try { - return server.getRoomChatId(roomId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("GetRoomChatId error", ex); } return null; } public UUID getTableChatId(UUID tableId) { + GetTableChatId method = new GetTableChatId(connection, tableId); try { - return server.getTableChatId(tableId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("GetTableChatId error", ex); } return null; } public UUID getGameChatId(UUID gameId) { + GetGameChatId method = new GetGameChatId(connection, gameId); try { - return server.getGameChatId(gameId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("GetGameChatId error", ex); } return null; } public TableView getTable(UUID roomId, UUID tableId) { + GetTable method = new GetTable(connection, roomId, tableId); try { - return server.getTable(roomId, tableId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("GetTable error", ex); } return null; } public boolean watchTable(UUID roomId, UUID tableId) { + WatchTable method = new WatchTable(connection, sessionId, roomId, tableId); try { - server.watchTable(sessionId, roomId, tableId); - return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("WatchTable error", ex); } return false; } public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) { + JoinTable method = new JoinTable(connection, sessionId, roomId, tableId, playerName, playerType, skill, deckList); try { - return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList); - } catch (RemoteException ex) { - handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (GameException ex) { handleGameException(ex); + } catch (MageException ex) { + logger.fatal("JoinTable error", ex); } return false; } public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill) { + JoinTournamentTable method = new JoinTournamentTable(connection, sessionId, roomId, tableId, playerName, playerType, skill); try { - return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill); - } catch (RemoteException ex) { - handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (GameException ex) { handleGameException(ex); + } catch (MageException ex) { + logger.fatal("JoinTournamentTable error", ex); } return false; } public Collection getTables(UUID roomId) throws MageRemoteException { + GetTables method = new GetTables(connection, roomId); try { - return server.getTables(roomId); - } catch (RemoteException ex) { - handleRemoteException(ex); - throw new MageRemoteException(); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); - throw new MageRemoteException(); + logger.fatal("GetTables error", ex); } + return null; } public Collection getConnectedPlayers(UUID roomId) throws MageRemoteException { + GetConnectedPlayers method = new GetConnectedPlayers(connection, roomId); try { - return server.getConnectedPlayers(roomId); - } catch (RemoteException ex) { - handleRemoteException(ex); - throw new MageRemoteException(); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); - throw new MageRemoteException(); + logger.fatal("GetConnectedPlayers error", ex); } + return null; } public TournamentView getTournament(UUID tournamentId) throws MageRemoteException { + GetTournament method = new GetTournament(connection, tournamentId); try { - return server.getTournament(tournamentId); - } catch (RemoteException ex) { - handleRemoteException(ex); - throw new MageRemoteException(); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); - throw new MageRemoteException(); + logger.fatal("GetTable error", ex); } + return null; } public UUID getTournamentChatId(UUID tournamentId) { + GetTournamentChatId method = new GetTournamentChatId(connection, tournamentId); try { - return server.getTournamentChatId(tournamentId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("GetTournamentChatId error", ex); } return null; } public boolean sendPlayerUUID(UUID gameId, UUID data) { + SendPlayerUUID method = new SendPlayerUUID(connection, sessionId, gameId, data); try { - server.sendPlayerUUID(gameId, sessionId, data); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("SendPlayerUUID error", ex); } return false; } public boolean sendPlayerBoolean(UUID gameId, boolean data) { + SendPlayerBoolean method = new SendPlayerBoolean(connection, sessionId, gameId, data); try { - server.sendPlayerBoolean(gameId, sessionId, data); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("SendPlayerBoolean error", ex); } return false; } public boolean sendPlayerInteger(UUID gameId, int data) { + SendPlayerInteger method = new SendPlayerInteger(connection, sessionId, gameId, data); try { - server.sendPlayerInteger(gameId, sessionId, data); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("SendPlayerInteger error", ex); } return false; } public boolean sendPlayerString(UUID gameId, String data) { + SendPlayerString method = new SendPlayerString(connection, sessionId, gameId, data); try { - server.sendPlayerString(gameId, sessionId, data); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("SendPlayerString error", ex); } return false; } public DraftPickView sendCardPick(UUID draftId, UUID cardId) { + SendCardPick method = new SendCardPick(connection, sessionId, draftId, cardId); try { - return server.sendCardPick(draftId, sessionId, cardId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("SendCardPick error", ex); } return null; } public boolean joinChat(UUID chatId, ChatPanel chat) { + JoinChat method = new JoinChat(connection, sessionId, chatId, userName); try { - server.joinChat(chatId, sessionId, userName); + method.makeCall(); chats.put(chatId, chat); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("JoinChat error", ex); } return false; } public boolean leaveChat(UUID chatId) { + LeaveChat method = new LeaveChat(connection, sessionId, chatId); try { - server.leaveChat(chatId, sessionId); + method.makeCall(); chats.remove(chatId); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("LeaveChat error", ex); } return false; } public boolean sendChatMessage(UUID chatId, String message) { + SendChatMessage method = new SendChatMessage(connection, chatId, message, userName); try { - server.sendChatMessage(chatId, userName, message); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("SendChatMessage error", ex); } return false; } public boolean joinGame(UUID gameId) { + JoinGame method = new JoinGame(connection, sessionId, gameId); try { - server.joinGame(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("JoinGame error", ex); } return false; } public boolean joinDraft(UUID draftId) { + JoinDraft method = new JoinDraft(connection, sessionId, draftId); try { - server.joinDraft(draftId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("JoinDraft error", ex); } return false; } public boolean joinTournament(UUID tournamentId) { + JoinTournament method = new JoinTournament(connection, sessionId, tournamentId); try { - server.joinTournament(tournamentId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("JoinTournament error", ex); } return false; } public boolean watchGame(UUID gameId) { + WatchGame method = new WatchGame(connection, sessionId, gameId); try { - server.watchGame(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("WatchGame error", ex); } return false; } public boolean replayGame(UUID gameId) { + ReplayGame method = new ReplayGame(connection, sessionId, gameId); try { - server.replayGame(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("ReplayGame error", ex); } return false; } public TableView createTable(UUID roomId, MatchOptions matchOptions) { + CreateTable method = new CreateTable(connection, sessionId, roomId, matchOptions); try { - return server.createTable(sessionId, roomId, matchOptions); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("CreateTable error", ex); } return null; } public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) { + CreateTournamentTable method = new CreateTournamentTable(connection, sessionId, roomId, tournamentOptions); try { - return server.createTournamentTable(sessionId, roomId, tournamentOptions); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("CreateTournamentTable error", ex); } return null; } public boolean isTableOwner(UUID roomId, UUID tableId) { + IsTableOwner method = new IsTableOwner(connection, sessionId, roomId, tableId); try { - return server.isTableOwner(sessionId, roomId, tableId); - } catch (RemoteException ex) { - handleRemoteException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("IsTableOwner error", ex); } return false; } public boolean removeTable(UUID roomId, UUID tableId) { + RemoveTable method = new RemoveTable(connection, sessionId, roomId, tableId); try { - server.removeTable(sessionId, roomId, tableId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("RemoveTable error", ex); } return false; } public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) { + SwapSeats method = new SwapSeats(connection, sessionId, roomId, tableId, seatNum1, seatNum2); try { - server.swapSeats(sessionId, roomId, tableId, seatNum1, seatNum2); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("RemoveTable error", ex); } return false; } public boolean leaveTable(UUID roomId, UUID tableId) { + LeaveTable method = new LeaveTable(connection, sessionId, roomId, tableId); try { - server.leaveTable(sessionId, roomId, tableId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("LeaveTable error", ex); } return false; } public boolean startGame(UUID roomId, UUID tableId) { + StartGame method = new StartGame(connection, sessionId, roomId, tableId); try { - server.startMatch(sessionId, roomId, tableId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("StartGame error", ex); } return false; } public boolean startTournament(UUID roomId, UUID tableId) { + StartTournament method = new StartTournament(connection, sessionId, roomId, tableId); try { - server.startTournament(sessionId, roomId, tableId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("StartTournament error", ex); } return false; } public boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId) { + StartChallenge method = new StartChallenge(connection, sessionId, roomId, tableId, challengeId); try { - server.startChallenge(sessionId, roomId, tableId, challengeId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("StartChallenge error", ex); } return false; } public boolean submitDeck(UUID tableId, DeckCardLists deck) { + SubmitDeck method = new SubmitDeck(connection, sessionId, tableId, deck); try { - return server.submitDeck(sessionId, tableId, deck); - } catch (RemoteException ex) { - handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); + return method.makeCall(); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (GameException ex) { handleGameException(ex); + } catch (MageException ex) { + logger.fatal("SubmitDeck error", ex); } return false; } public boolean concedeGame(UUID gameId) { + ConcedeGame method = new ConcedeGame(connection, sessionId, gameId); try { - server.concedeGame(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("ConcedeGame error", ex); } return false; } public boolean stopWatching(UUID gameId) { + StopWatching method = new StopWatching(connection, sessionId, gameId); try { - server.stopWatching(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("StopWatching error", ex); } return false; } public boolean startReplay(UUID gameId) { + StartReplay method = new StartReplay(connection, sessionId, gameId); try { - server.startReplay(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("StartReplay error", ex); } return false; } public boolean stopReplay(UUID gameId) { + StopReplay method = new StopReplay(connection, sessionId, gameId); try { - server.stopReplay(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("StopReplay error", ex); } return false; } public boolean nextPlay(UUID gameId) { + NextPlay method = new NextPlay(connection, sessionId, gameId); try { - server.nextPlay(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("NextPlay error", ex); } return false; } public boolean previousPlay(UUID gameId) { + PreviousPlay method = new PreviousPlay(connection, sessionId, gameId); try { - server.previousPlay(gameId, sessionId); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("PreviousPlay error", ex); } return false; } public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) { + Cheat method = new Cheat(connection, sessionId, gameId, playerId, deckList); try { - server.cheat(gameId, sessionId, playerId, deckList); + method.makeCall(); return true; - } catch (RemoteException ex) { - handleRemoteException(ex); + } catch (ServerUnavailable ex) { + handleServerUnavailable(ex); } catch (MageException ex) { - handleMageException(ex); + logger.fatal("Cheat error", ex); } return false; } - private void handleRemoteException(RemoteException ex) { - logger.fatal("Communication error", ex); +// private void handleRemoteException(RemoteException ex) { +// logger.fatal("Communication error", ex); +// disconnect(false); +// } + +// private void handleMageException(MageException ex) { +// logger.fatal("Server error", ex); +// disconnect(false); +// } + + private void handleServerUnavailable(ServerUnavailable ex) { + logger.fatal("server unavailable - ", ex); disconnect(false); } - - private void handleMageException(MageException ex) { - logger.fatal("Server error", ex); - disconnect(false); - } - + private void handleGameException(GameException ex) { logger.warn(ex.getMessage()); JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); @@ -803,9 +862,9 @@ public class Session { return ui; } - public Server getServerRef() { - return server; - } +// public Server getServerRef() { +// return server; +// } class ServerPinger implements Runnable { diff --git a/Mage.Common/src/mage/interfaces/PluginException.java b/Mage.Common/src/mage/interfaces/PluginException.java index ffd0ef8bd97..c7fc3f76fcb 100644 --- a/Mage.Common/src/mage/interfaces/PluginException.java +++ b/Mage.Common/src/mage/interfaces/PluginException.java @@ -1,5 +1,7 @@ package mage.interfaces; +import mage.MageException; + /** * Exception thrown by plugin on errors. * diff --git a/Mage.Common/src/mage/interfaces/Server.java b/Mage.Common/src/mage/interfaces/Server.java index 08a9510c7ed..81db21972c2 100644 --- a/Mage.Common/src/mage/interfaces/Server.java +++ b/Mage.Common/src/mage/interfaces/Server.java @@ -28,6 +28,7 @@ package mage.interfaces; +import mage.MageException; import mage.game.match.MatchOptions; import java.rmi.Remote; import java.rmi.RemoteException; @@ -53,7 +54,6 @@ public interface Server extends Remote, CallbackServer { public UUID registerClient(String userName, UUID clientId, MageVersion version) throws RemoteException, MageException; public UUID registerAdmin(String password, MageVersion version) throws RemoteException, MageException; public void deregisterClient(UUID sessionId) throws RemoteException, MageException; - public void ack(String message, UUID sessionId) throws RemoteException, MageException; public boolean ping(UUID sessionId) throws RemoteException, MageException; public ServerState getServerState() throws RemoteException, MageException; diff --git a/Mage.Common/src/mage/interfaces/callback/CallbackAck.java b/Mage.Common/src/mage/interfaces/callback/CallbackAck.java new file mode 100644 index 00000000000..2399d14e3ac --- /dev/null +++ b/Mage.Common/src/mage/interfaces/callback/CallbackAck.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.interfaces.callback; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CallbackAck { + + private boolean ack; + private int value; + + public void clear() { + ack = false; + value = 0; + } + + public boolean isAck() { + return ack; + } + + public void setAck(boolean ack) { + this.ack = ack; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + +} diff --git a/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java b/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java index 95a6ecdc40b..ab8d1282b57 100644 --- a/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java +++ b/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java @@ -31,6 +31,9 @@ package mage.interfaces.callback; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import mage.remote.Connection; +import mage.remote.method.Ack; +import mage.remote.method.Callback; import org.apache.log4j.Logger; /** @@ -43,12 +46,13 @@ public class CallbackClientDaemon extends Thread { private static ExecutorService callbackExecutor = Executors.newCachedThreadPool(); private final CallbackClient client; - private final CallbackServer server; + private final Connection connection; private final UUID id; + private boolean end = false; - public CallbackClientDaemon(UUID id, CallbackClient client, CallbackServer server) { + public CallbackClientDaemon(UUID id, CallbackClient client, Connection connection) { this.client = client; - this.server = server; + this.connection = connection; this.id = id; setDaemon(true); start(); @@ -56,25 +60,38 @@ public class CallbackClientDaemon extends Thread { @Override public void run() { - try { - while(true) { - final ClientCallback callback = server.callback(id); - callbackExecutor.submit( - new Runnable() { - @Override - public void run() { - try { - client.processCallback(callback); + try { + while(!end) { + try { + Callback callbackMethod = new Callback(connection, id); + final ClientCallback callback = callbackMethod.makeCall(); + Ack ackMethod = new Ack(connection, id, callback.getMessageId()); + ackMethod.makeCall(); + callbackExecutor.submit( + new Runnable() { + @Override + public void run() { + try { + client.processCallback(callback); + } + catch (Exception ex) { + logger.fatal("CallbackClientDaemon error ", ex); + } + } } - catch (Exception ex) { - logger.fatal("CallbackClientDaemon error ", ex); - } - } + ); + } catch (CallbackException ex) { + logger.fatal("Callback failed ", ex); } - ); - } - } catch(Exception ex) { + } + } catch(Exception ex) { logger.fatal("CallbackClientDaemon error ", ex); - } - } + } + } + + public void stopDaemon() { + end = true; + callbackExecutor.shutdown(); + } + } diff --git a/Mage.Common/src/mage/interfaces/callback/CallbackException.java b/Mage.Common/src/mage/interfaces/callback/CallbackException.java new file mode 100644 index 00000000000..1d0b973602c --- /dev/null +++ b/Mage.Common/src/mage/interfaces/callback/CallbackException.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.interfaces.callback; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CallbackException extends Exception { + + public CallbackException(String message) { + super(message); + } + + public CallbackException(Throwable t) { + super(t); + } + +} diff --git a/Mage.Common/src/mage/interfaces/callback/CallbackServer.java b/Mage.Common/src/mage/interfaces/callback/CallbackServer.java index f3e1b8ce35c..1c5cf2a479a 100644 --- a/Mage.Common/src/mage/interfaces/callback/CallbackServer.java +++ b/Mage.Common/src/mage/interfaces/callback/CallbackServer.java @@ -37,6 +37,7 @@ import java.util.UUID; */ public interface CallbackServer { - public ClientCallback callback(UUID clientId) throws RemoteException; + public ClientCallback callback(UUID clientId) throws RemoteException, CallbackException; + public void ack(int messageId, UUID sessionId) throws RemoteException, CallbackException; } diff --git a/Mage.Common/src/mage/remote/AbstractRemoteMethodCall.java b/Mage.Common/src/mage/remote/AbstractRemoteMethodCall.java new file mode 100644 index 00000000000..1eb97d7ef70 --- /dev/null +++ b/Mage.Common/src/mage/remote/AbstractRemoteMethodCall.java @@ -0,0 +1,102 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ +import java.rmi.*; +import mage.interfaces.Server; +import org.apache.log4j.Logger; + +public abstract class AbstractRemoteMethodCall { + + private final static Logger logger = Logger.getLogger(AbstractRemoteMethodCall.class); + + public T makeCall() throws ServerUnavailable, E { + RetryStrategy strategy = getRetryStrategy(); + while (strategy.shouldRetry()) { + Server server = getServer(); + if (null == server) { + throw new ServerUnavailable(); + } + try { + return performRemoteCall(server); + } + catch (RemoteException remoteException) { + try { + remoteExceptionOccurred(remoteException); + strategy.remoteExceptionOccurred(); + } + catch (RetryException retryException) { + handleRetryException(server); + } + } + } + return null; + } + +/* + The next 4 methods define the core behavior. Of these, two must + be implemented by the subclass (and so are left abstract). The + remaining three can be altered to provide customized retry handling. +*/ + +/** + getRemoteObject is a template method which should, in most cases, + return the stub. +*/ + + protected abstract Server getServer() throws ServerUnavailable; + +/** + performRemoteCall is a template method which actually makes the remote + method invocation. +*/ + protected abstract T performRemoteCall(Server server) throws RemoteException, E; + + + protected RetryStrategy getRetryStrategy() { + return new AdditiveWaitRetryStrategy(); + } + + protected void remoteExceptionOccurred(RemoteException remoteException) { + /* ignored in based class. */ + } + + protected void handleRetryException(Server server) throws ServerUnavailable { + logger.fatal("Repeated attempts to communicate with " + server + " failed."); + throw new ServerUnavailable(); + } +} \ No newline at end of file diff --git a/Mage.Common/src/mage/remote/AdditiveWaitRetryStrategy.java b/Mage.Common/src/mage/remote/AdditiveWaitRetryStrategy.java new file mode 100644 index 00000000000..13d97caeca5 --- /dev/null +++ b/Mage.Common/src/mage/remote/AdditiveWaitRetryStrategy.java @@ -0,0 +1,75 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ + +/** + The most commonly used retry strategy; it extends the waiting + period by a constant amount with each retry. + + Note that the default version of this (e.g. the one with a + zero argument constructor) will make 3 calls and wind up waiting + approximately 11 seconds (zero wait for the first call, 3 seconds + for the second call, and 8 seconds for the third call). These + wait times are pretty small, and are usually dwarfed by socket + timeouts when network difficulties occur anyway. +*/ + +public class AdditiveWaitRetryStrategy extends RetryStrategy { + public static final long STARTING_WAIT_TIME = 3000; + public static final long WAIT_TIME_INCREMENT = 5000; + + private long currentTimeToWait; + private long waitTimeIncrement; + + public AdditiveWaitRetryStrategy () { + this(DEFAULT_NUMBER_OF_RETRIES , STARTING_WAIT_TIME, WAIT_TIME_INCREMENT); + } + + public AdditiveWaitRetryStrategy (int numberOfRetries, long startingWaitTime, long waitTimeIncrement) { + super(numberOfRetries); + this.currentTimeToWait = startingWaitTime; + this.waitTimeIncrement = waitTimeIncrement; + } + + @Override + protected long getTimeToWait() { + long returnValue = currentTimeToWait; + currentTimeToWait += waitTimeIncrement; + return returnValue; + } +} \ No newline at end of file diff --git a/Mage.Common/src/mage/utils/Connection.java b/Mage.Common/src/mage/remote/Connection.java similarity index 83% rename from Mage.Common/src/mage/utils/Connection.java rename to Mage.Common/src/mage/remote/Connection.java index e00d78740de..e8b5be0181f 100644 --- a/Mage.Common/src/mage/utils/Connection.java +++ b/Mage.Common/src/mage/remote/Connection.java @@ -26,7 +26,11 @@ * or implied, of BetaSteward_at_googlemail.com. */ -package mage.utils; +package mage.remote; + +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import mage.interfaces.Server; /** * @@ -44,6 +48,30 @@ public class Connection { private String proxyUsername; private String proxyPassword; + protected Server getServer() { + Server server = null; + try { + Registry reg = LocateRegistry.getRegistry(host, port); + server = (Server) reg.lookup("mage-server"); + } + catch (Exception ignored) {} + return server; + } + + @Override + public int hashCode() { + return (host + Integer.toString(port) + proxyType.toString()).hashCode(); + } + + @Override + public boolean equals(Object object) { + if (! (object instanceof Connection)) { + return false; + } + Connection otherConnection = (Connection) object; + return hashCode() == otherConnection.hashCode(); + } + public ProxyType getProxyType() { return proxyType; } diff --git a/Mage.Common/src/mage/remote/RemoteMethodCall.java b/Mage.Common/src/mage/remote/RemoteMethodCall.java new file mode 100644 index 00000000000..177b1841175 --- /dev/null +++ b/Mage.Common/src/mage/remote/RemoteMethodCall.java @@ -0,0 +1,81 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +import java.rmi.*; +import mage.interfaces.Server; +import org.apache.log4j.Logger; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ + +public abstract class RemoteMethodCall extends AbstractRemoteMethodCall { + + protected final static Logger logger = Logger.getLogger(RemoteMethodCall.class); + + protected Connection connection; + + public RemoteMethodCall(Connection connection){ + this.connection = connection; + } + + @Override + public T makeCall() throws ServerUnavailable, E { + T returnValue = null; + try { + returnValue = super.makeCall(); + } + finally { + ServerCache.noLongerUsingServer(connection); + } + return returnValue; + } + + @Override + protected Server getServer() throws ServerUnavailable { + try { + Server stub = ServerCache.getServer(connection); + return stub; + } + catch (ServerUnavailable serverUnavailable) { + logger.fatal("Can't find stub for server " + connection); + throw serverUnavailable; + } + } + + protected void remoteExceptionOccured(RemoteException remoteException) { + ServerCache.removeServerFromCache(connection); + } +} diff --git a/Mage.Common/src/mage/remote/RetryException.java b/Mage.Common/src/mage/remote/RetryException.java new file mode 100644 index 00000000000..e291189f3b8 --- /dev/null +++ b/Mage.Common/src/mage/remote/RetryException.java @@ -0,0 +1,51 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +import java.io.*; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ + +public class RetryException extends Exception implements Externalizable +{ + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException { + } +} diff --git a/Mage.Common/src/mage/remote/RetryStrategy.java b/Mage.Common/src/mage/remote/RetryStrategy.java new file mode 100644 index 00000000000..58274d402c5 --- /dev/null +++ b/Mage.Common/src/mage/remote/RetryStrategy.java @@ -0,0 +1,72 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ +public abstract class RetryStrategy { + public static final int DEFAULT_NUMBER_OF_RETRIES = 3; + private int _numberOfTriesLeft; + + public RetryStrategy() { + this(DEFAULT_NUMBER_OF_RETRIES); + } + + public RetryStrategy(int numberOfRetries){ + _numberOfTriesLeft = numberOfRetries; + } + + public boolean shouldRetry() { + return (0 < _numberOfTriesLeft); + } + + public void remoteExceptionOccurred() throws RetryException { + _numberOfTriesLeft --; + if (!shouldRetry()) { + throw new RetryException(); + } + waitUntilNextTry(); + } + + protected abstract long getTimeToWait(); + + private void waitUntilNextTry() { + long timeToWait = getTimeToWait(); + try { + Thread.sleep(timeToWait ); + } + catch (InterruptedException ignored) {} + } +} \ No newline at end of file diff --git a/Mage.Common/src/mage/remote/ServerCache.java b/Mage.Common/src/mage/remote/ServerCache.java new file mode 100644 index 00000000000..6daa5db3756 --- /dev/null +++ b/Mage.Common/src/mage/remote/ServerCache.java @@ -0,0 +1,71 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +import java.util.HashMap; +import mage.interfaces.Server; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ +public class ServerCache +{ + private static HashMap servers = new HashMap(); + + public static Server getServer(Connection connection) throws ServerUnavailable + { + Server returnValue = servers.get(connection); + if (returnValue == null) { + returnValue = connection.getServer() ; + if (returnValue != null) { + servers.put(connection, returnValue); + } + else { + throw new ServerUnavailable(); + } + } + return returnValue; + + } + + public static void noLongerUsingServer(Connection connection) { + /* + Needs to be implemented if we take cleaning up the cache seriously. + */ + } + + public static void removeServerFromCache(Connection connection) { + servers.remove(connection); + } +} diff --git a/Mage.Common/src/mage/remote/ServerUnavailable.java b/Mage.Common/src/mage/remote/ServerUnavailable.java new file mode 100644 index 00000000000..605783192a2 --- /dev/null +++ b/Mage.Common/src/mage/remote/ServerUnavailable.java @@ -0,0 +1,51 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote; + +import java.io.*; + +/** + * Adopted from the code by William Grosso, author of Java RMI + * 10/17/2001 + * + * http://www.onjava.com/pub/a/onjava/2001/10/17/rmi.html + * oreillynet.com Copyright © 2000 O'Reilly & Associates, Inc. + * + * @author BetaSteward_at_googlemail.com + */ + +public class ServerUnavailable extends Exception implements Externalizable +{ + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException{ + } +} diff --git a/Mage.Common/src/mage/remote/method/Ack.java b/Mage.Common/src/mage/remote/method/Ack.java new file mode 100644 index 00000000000..4f0bae2d572 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/Ack.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.interfaces.Server; +import mage.interfaces.callback.CallbackException; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class Ack extends RemoteMethodCall { + + private UUID sessionId; + private int messageId; + + public Ack(Connection connection, UUID sessionId, int messageId) { + super(connection); + this.sessionId = sessionId; + this.messageId = messageId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, CallbackException { + server.ack(messageId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/Callback.java b/Mage.Common/src/mage/remote/method/Callback.java new file mode 100644 index 00000000000..69efea0cd92 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/Callback.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.interfaces.Server; +import mage.interfaces.callback.CallbackException; +import mage.interfaces.callback.ClientCallback; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class Callback extends RemoteMethodCall { + + private UUID sessionId; + + public Callback(Connection connection, UUID sessionId) { + super(connection); + this.sessionId = sessionId; + } + + @Override + protected ClientCallback performRemoteCall(Server server) throws RemoteException, CallbackException { + return server.callback(sessionId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/Cheat.java b/Mage.Common/src/mage/remote/method/Cheat.java new file mode 100644 index 00000000000..d643174aca8 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/Cheat.java @@ -0,0 +1,64 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.cards.decks.DeckCardLists; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class Cheat extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + private UUID playerId; + private DeckCardLists deckList; + + public Cheat(Connection connection, UUID sessionId, UUID gameId, UUID playerId, DeckCardLists deckList) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + this.playerId = playerId; + this.deckList = deckList; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.cheat(gameId, sessionId, playerId, deckList); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/ConcedeGame.java b/Mage.Common/src/mage/remote/method/ConcedeGame.java new file mode 100644 index 00000000000..2913061b0b4 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/ConcedeGame.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class ConcedeGame extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public ConcedeGame(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.concedeGame(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/CreateTable.java b/Mage.Common/src/mage/remote/method/CreateTable.java new file mode 100644 index 00000000000..09ef9d06c14 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/CreateTable.java @@ -0,0 +1,61 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.game.match.MatchOptions; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.view.TableView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CreateTable extends RemoteMethodCall { + + private UUID roomId; + private UUID sessionId; + private MatchOptions matchOptions; + + public CreateTable(Connection connection, UUID sessionId, UUID roomId, MatchOptions matchOptions) { + super(connection); + this.roomId = roomId; + this.sessionId = sessionId; + this.matchOptions = matchOptions; + } + + @Override + protected TableView performRemoteCall(Server server) throws RemoteException, MageException { + return server.createTable(sessionId, roomId, matchOptions); + } + +} diff --git a/Mage.Common/src/mage/remote/method/CreateTournamentTable.java b/Mage.Common/src/mage/remote/method/CreateTournamentTable.java new file mode 100644 index 00000000000..f3b0ea13397 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/CreateTournamentTable.java @@ -0,0 +1,61 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.game.tournament.TournamentOptions; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.view.TableView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class CreateTournamentTable extends RemoteMethodCall { + + private UUID roomId; + private UUID sessionId; + private TournamentOptions tournamentOptions; + + public CreateTournamentTable(Connection connection, UUID sessionId, UUID roomId, TournamentOptions tournamentOptions) { + super(connection); + this.roomId = roomId; + this.sessionId = sessionId; + this.tournamentOptions = tournamentOptions; + } + + @Override + protected TableView performRemoteCall(Server server) throws RemoteException, MageException { + return server.createTournamentTable(sessionId, roomId, tournamentOptions); + } + +} diff --git a/Mage.Common/src/mage/remote/method/DeregisterClient.java b/Mage.Common/src/mage/remote/method/DeregisterClient.java new file mode 100644 index 00000000000..84ec4427f6a --- /dev/null +++ b/Mage.Common/src/mage/remote/method/DeregisterClient.java @@ -0,0 +1,57 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class DeregisterClient extends RemoteMethodCall { + + private UUID sessionId; + + public DeregisterClient(Connection connection, UUID sessionId) { + super(connection); + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.deregisterClient(sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java b/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java new file mode 100644 index 00000000000..cf9143e3ca2 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java @@ -0,0 +1,57 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.List; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetConnectedPlayers extends RemoteMethodCall, MageException> { + + private UUID roomId; + + public GetConnectedPlayers(Connection connection, UUID roomId) { + super(connection); + this.roomId = roomId; + } + + @Override + protected List performRemoteCall(Server server) throws RemoteException, MageException { + return server.getConnectedPlayers(roomId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetGameChatId.java b/Mage.Common/src/mage/remote/method/GetGameChatId.java new file mode 100644 index 00000000000..72161114399 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetGameChatId.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetGameChatId extends RemoteMethodCall { + + private UUID gameId; + + public GetGameChatId(Connection connection, UUID gameId) { + super(connection); + this.gameId = gameId; + } + + @Override + protected UUID performRemoteCall(Server server) throws RemoteException, MageException { + return server.getGameChatId(gameId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetMainRoomId.java b/Mage.Common/src/mage/remote/method/GetMainRoomId.java new file mode 100644 index 00000000000..0df86815232 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetMainRoomId.java @@ -0,0 +1,54 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetMainRoomId extends RemoteMethodCall { + + + public GetMainRoomId(Connection connection) { + super(connection); + } + + @Override + protected UUID performRemoteCall(Server server) throws RemoteException, MageException { + return server.getMainRoomId(); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetRoomChatId.java b/Mage.Common/src/mage/remote/method/GetRoomChatId.java new file mode 100644 index 00000000000..bb0ee926ec5 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetRoomChatId.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetRoomChatId extends RemoteMethodCall { + + private UUID roomId; + + public GetRoomChatId(Connection connection, UUID roomId) { + super(connection); + this.roomId = roomId; + } + + @Override + protected UUID performRemoteCall(Server server) throws RemoteException, MageException { + return server.getRoomChatId(roomId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetServerState.java b/Mage.Common/src/mage/remote/method/GetServerState.java new file mode 100644 index 00000000000..ea180c2aab6 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetServerState.java @@ -0,0 +1,52 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import mage.MageException; +import mage.interfaces.Server; +import mage.interfaces.ServerState; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetServerState extends RemoteMethodCall { + + public GetServerState(Connection connection) { + super(connection); + } + + @Override + protected ServerState performRemoteCall(Server server) throws RemoteException, MageException { + return server.getServerState(); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetTable.java b/Mage.Common/src/mage/remote/method/GetTable.java new file mode 100644 index 00000000000..348aa43aa30 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetTable.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.view.TableView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetTable extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + + public GetTable(Connection connection, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + } + + @Override + protected TableView performRemoteCall(Server server) throws RemoteException, MageException { + return server.getTable(roomId, tableId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetTableChatId.java b/Mage.Common/src/mage/remote/method/GetTableChatId.java new file mode 100644 index 00000000000..6aaa48354e6 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetTableChatId.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetTableChatId extends RemoteMethodCall { + + private UUID tableId; + + public GetTableChatId(Connection connection, UUID tableId) { + super(connection); + this.tableId = tableId; + } + + @Override + protected UUID performRemoteCall(Server server) throws RemoteException, MageException { + return server.getTableChatId(tableId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetTables.java b/Mage.Common/src/mage/remote/method/GetTables.java new file mode 100644 index 00000000000..04e8cd7f35e --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetTables.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.List; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.view.TableView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetTables extends RemoteMethodCall, MageException> { + + private UUID roomId; + + public GetTables(Connection connection, UUID roomId) { + super(connection); + this.roomId = roomId; + } + + @Override + protected List performRemoteCall(Server server) throws RemoteException, MageException { + return server.getTables(roomId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetTournament.java b/Mage.Common/src/mage/remote/method/GetTournament.java new file mode 100644 index 00000000000..a0282fcf465 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetTournament.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.view.TournamentView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetTournament extends RemoteMethodCall { + + private UUID tournamentId; + + public GetTournament(Connection connection, UUID tournamentId) { + super(connection); + this.tournamentId = tournamentId; + } + + @Override + protected TournamentView performRemoteCall(Server server) throws RemoteException, MageException { + return server.getTournament(tournamentId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/GetTournamentChatId.java b/Mage.Common/src/mage/remote/method/GetTournamentChatId.java new file mode 100644 index 00000000000..18443da53ea --- /dev/null +++ b/Mage.Common/src/mage/remote/method/GetTournamentChatId.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class GetTournamentChatId extends RemoteMethodCall { + + private UUID tournamentId; + + public GetTournamentChatId(Connection connection, UUID tournamentId) { + super(connection); + this.tournamentId = tournamentId; + } + + @Override + protected UUID performRemoteCall(Server server) throws RemoteException, MageException { + return server.getTournamentChatId(tournamentId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/IsTableOwner.java b/Mage.Common/src/mage/remote/method/IsTableOwner.java new file mode 100644 index 00000000000..79754068bf4 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/IsTableOwner.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class IsTableOwner extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + + public IsTableOwner(Connection connection, UUID sessionId, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + } + + @Override + protected Boolean performRemoteCall(Server server) throws RemoteException, MageException { + return server.isTableOwner(sessionId, roomId, tableId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/JoinChat.java b/Mage.Common/src/mage/remote/method/JoinChat.java new file mode 100644 index 00000000000..a69cc9a2f9c --- /dev/null +++ b/Mage.Common/src/mage/remote/method/JoinChat.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class JoinChat extends RemoteMethodCall { + + private UUID chatId; + private UUID sessionId; + private String userName; + + public JoinChat(Connection connection, UUID sessionId, UUID chatId, String userName) { + super(connection); + this.chatId = chatId; + this.sessionId = sessionId; + this.userName = userName; + } + + @Override + protected Void performRemoteCall(Server server) throws MageException, RemoteException { + server.joinChat(chatId, sessionId, userName); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/JoinDraft.java b/Mage.Common/src/mage/remote/method/JoinDraft.java new file mode 100644 index 00000000000..507b786cbbf --- /dev/null +++ b/Mage.Common/src/mage/remote/method/JoinDraft.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class JoinDraft extends RemoteMethodCall { + + private UUID draftId; + private UUID sessionId; + + public JoinDraft(Connection connection, UUID sessionId, UUID draftId) { + super(connection); + this.draftId = draftId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.joinDraft(draftId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/JoinGame.java b/Mage.Common/src/mage/remote/method/JoinGame.java new file mode 100644 index 00000000000..01a1a6b2fe1 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/JoinGame.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class JoinGame extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public JoinGame(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.joinGame(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/JoinTable.java b/Mage.Common/src/mage/remote/method/JoinTable.java new file mode 100644 index 00000000000..057036262bf --- /dev/null +++ b/Mage.Common/src/mage/remote/method/JoinTable.java @@ -0,0 +1,69 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.cards.decks.DeckCardLists; +import mage.MageException; +import mage.game.GameException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class JoinTable extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + private String playerName; + private String playerType; + private int skill; + private DeckCardLists deckList; + + public JoinTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + this.playerName = playerName; + this.playerType = playerType; + this.skill = skill; + this.deckList = deckList; + } + + @Override + protected Boolean performRemoteCall(Server server) throws MageException, GameException, RemoteException { + return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList); + } + +} diff --git a/Mage.Common/src/mage/remote/method/JoinTournament.java b/Mage.Common/src/mage/remote/method/JoinTournament.java new file mode 100644 index 00000000000..35a8f272a4a --- /dev/null +++ b/Mage.Common/src/mage/remote/method/JoinTournament.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class JoinTournament extends RemoteMethodCall { + + private UUID tournamentId; + private UUID sessionId; + + public JoinTournament(Connection connection, UUID sessionId, UUID tournamentId) { + super(connection); + this.tournamentId = tournamentId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.joinTournament(tournamentId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/JoinTournamentTable.java b/Mage.Common/src/mage/remote/method/JoinTournamentTable.java new file mode 100644 index 00000000000..b7a0107cf6b --- /dev/null +++ b/Mage.Common/src/mage/remote/method/JoinTournamentTable.java @@ -0,0 +1,67 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.cards.decks.DeckCardLists; +import mage.MageException; +import mage.game.GameException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class JoinTournamentTable extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + private String playerName; + private String playerType; + private int skill; + + public JoinTournamentTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId, String playerName, String playerType, int skill) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + this.playerName = playerName; + this.playerType = playerType; + this.skill = skill; + } + + @Override + protected Boolean performRemoteCall(Server server) throws MageException, GameException, RemoteException { + return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill); + } + +} diff --git a/Mage.Common/src/mage/remote/method/LeaveChat.java b/Mage.Common/src/mage/remote/method/LeaveChat.java new file mode 100644 index 00000000000..f111fab30ee --- /dev/null +++ b/Mage.Common/src/mage/remote/method/LeaveChat.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class LeaveChat extends RemoteMethodCall { + + private UUID chatId; + private UUID sessionId; + + public LeaveChat(Connection connection, UUID sessionId, UUID chatId) { + super(connection); + this.chatId = chatId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws MageException, RemoteException { + server.leaveChat(chatId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/LeaveTable.java b/Mage.Common/src/mage/remote/method/LeaveTable.java new file mode 100644 index 00000000000..be0f3ec66f7 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/LeaveTable.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class LeaveTable extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + + public LeaveTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.leaveTable(sessionId, roomId, tableId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/NextPlay.java b/Mage.Common/src/mage/remote/method/NextPlay.java new file mode 100644 index 00000000000..24a747096da --- /dev/null +++ b/Mage.Common/src/mage/remote/method/NextPlay.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class NextPlay extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public NextPlay(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.nextPlay(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/Ping.java b/Mage.Common/src/mage/remote/method/Ping.java new file mode 100644 index 00000000000..f164368b6f5 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/Ping.java @@ -0,0 +1,55 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class Ping extends RemoteMethodCall { + + private UUID sessionId; + + public Ping(Connection connection, UUID sessionId) { + super(connection); + this.sessionId = sessionId; + } + + @Override + protected Boolean performRemoteCall(Server server) throws RemoteException, MageException { + return server.ping(sessionId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/PreviousPlay.java b/Mage.Common/src/mage/remote/method/PreviousPlay.java new file mode 100644 index 00000000000..b40a2f0f43e --- /dev/null +++ b/Mage.Common/src/mage/remote/method/PreviousPlay.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class PreviousPlay extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public PreviousPlay(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.previousPlay(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/RegisterClient.java b/Mage.Common/src/mage/remote/method/RegisterClient.java new file mode 100644 index 00000000000..8dcd4490cee --- /dev/null +++ b/Mage.Common/src/mage/remote/method/RegisterClient.java @@ -0,0 +1,61 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.utils.MageVersion; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class RegisterClient extends RemoteMethodCall { + + private String userName; + private UUID clientId; + private MageVersion version; + + public RegisterClient(Connection connection, String userName, UUID clientId, MageVersion version) { + super(connection); + this.userName = userName; + this.clientId = clientId; + this.version = version; + } + + @Override + protected UUID performRemoteCall(Server server) throws RemoteException, MageException { + return server.registerClient(userName, clientId, version); + } + +} diff --git a/Mage.Common/src/mage/remote/method/RemoveTable.java b/Mage.Common/src/mage/remote/method/RemoveTable.java new file mode 100644 index 00000000000..2067b56ecf1 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/RemoveTable.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class RemoveTable extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + + public RemoveTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.removeTable(sessionId, roomId, tableId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/ReplayGame.java b/Mage.Common/src/mage/remote/method/ReplayGame.java new file mode 100644 index 00000000000..ab9627630c2 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/ReplayGame.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class ReplayGame extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public ReplayGame(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.replayGame(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/SendCardPick.java b/Mage.Common/src/mage/remote/method/SendCardPick.java new file mode 100644 index 00000000000..673d216e81c --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SendCardPick.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; +import mage.view.DraftPickView; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SendCardPick extends RemoteMethodCall { + + private UUID sessionId; + private UUID draftId; + private UUID cardId; + + public SendCardPick(Connection connection, UUID sessionId, UUID draftId, UUID cardId) { + super(connection); + this.sessionId = sessionId; + this.draftId = draftId; + this.cardId = cardId; + } + + @Override + protected DraftPickView performRemoteCall(Server server) throws RemoteException, MageException { + return server.sendCardPick(draftId, sessionId, cardId); + } + +} diff --git a/Mage.Common/src/mage/remote/method/SendChatMessage.java b/Mage.Common/src/mage/remote/method/SendChatMessage.java new file mode 100644 index 00000000000..c73355c8e01 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SendChatMessage.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SendChatMessage extends RemoteMethodCall { + + private UUID chatId; + private String message; + private String userName; + + public SendChatMessage(Connection connection, UUID chatId, String message, String userName) { + super(connection); + this.chatId = chatId; + this.message = message; + this.userName = userName; + } + + @Override + protected Void performRemoteCall(Server server) throws MageException, RemoteException { + server.sendChatMessage(chatId, userName, message); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java b/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java new file mode 100644 index 00000000000..572227fae97 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SendPlayerBoolean extends RemoteMethodCall { + + private UUID sessionId; + private UUID gameId; + private Boolean data; + + public SendPlayerBoolean(Connection connection, UUID sessionId, UUID gameId, Boolean data) { + super(connection); + this.sessionId = sessionId; + this.gameId = gameId; + this.data = data; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.sendPlayerBoolean(gameId, sessionId, data); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/SendPlayerInteger.java b/Mage.Common/src/mage/remote/method/SendPlayerInteger.java new file mode 100644 index 00000000000..97e9fa1e1d7 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SendPlayerInteger.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SendPlayerInteger extends RemoteMethodCall { + + private UUID sessionId; + private UUID gameId; + private Integer data; + + public SendPlayerInteger(Connection connection, UUID sessionId, UUID gameId, Integer data) { + super(connection); + this.sessionId = sessionId; + this.gameId = gameId; + this.data = data; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.sendPlayerInteger(gameId, sessionId, data); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/SendPlayerString.java b/Mage.Common/src/mage/remote/method/SendPlayerString.java new file mode 100644 index 00000000000..0925961e722 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SendPlayerString.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SendPlayerString extends RemoteMethodCall { + + private UUID sessionId; + private UUID gameId; + private String data; + + public SendPlayerString(Connection connection, UUID sessionId, UUID gameId, String data) { + super(connection); + this.sessionId = sessionId; + this.gameId = gameId; + this.data = data; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.sendPlayerString(gameId, sessionId, data); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/SendPlayerUUID.java b/Mage.Common/src/mage/remote/method/SendPlayerUUID.java new file mode 100644 index 00000000000..ed7c7ad0451 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SendPlayerUUID.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SendPlayerUUID extends RemoteMethodCall { + + private UUID sessionId; + private UUID gameId; + private UUID data; + + public SendPlayerUUID(Connection connection, UUID sessionId, UUID gameId, UUID data) { + super(connection); + this.sessionId = sessionId; + this.gameId = gameId; + this.data = data; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.sendPlayerUUID(gameId, sessionId, data); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/StartChallenge.java b/Mage.Common/src/mage/remote/method/StartChallenge.java new file mode 100644 index 00000000000..c9120c13fc0 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/StartChallenge.java @@ -0,0 +1,62 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StartChallenge extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + private UUID challengeId; + + public StartChallenge(Connection connection, UUID sessionId, UUID roomId, UUID tableId, UUID challengeId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + this.challengeId = challengeId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.startChallenge(sessionId, roomId, tableId, challengeId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/StartGame.java b/Mage.Common/src/mage/remote/method/StartGame.java new file mode 100644 index 00000000000..9390289d5b7 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/StartGame.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StartGame extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + + public StartGame(Connection connection, UUID sessionId, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.startMatch(sessionId, roomId, tableId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/StartReplay.java b/Mage.Common/src/mage/remote/method/StartReplay.java new file mode 100644 index 00000000000..88aa4b95038 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/StartReplay.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StartReplay extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public StartReplay(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.startReplay(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/StartTournament.java b/Mage.Common/src/mage/remote/method/StartTournament.java new file mode 100644 index 00000000000..ab0a28bc7a7 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/StartTournament.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StartTournament extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + + public StartTournament(Connection connection, UUID sessionId, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.startTournament(sessionId, roomId, tableId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/StopReplay.java b/Mage.Common/src/mage/remote/method/StopReplay.java new file mode 100644 index 00000000000..3e9e425d9c5 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/StopReplay.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StopReplay extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public StopReplay(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.stopReplay(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/StopWatching.java b/Mage.Common/src/mage/remote/method/StopWatching.java new file mode 100644 index 00000000000..2ce2158e52d --- /dev/null +++ b/Mage.Common/src/mage/remote/method/StopWatching.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class StopWatching extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public StopWatching(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.stopWatching(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/SubmitDeck.java b/Mage.Common/src/mage/remote/method/SubmitDeck.java new file mode 100644 index 00000000000..74eed5cbb5c --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SubmitDeck.java @@ -0,0 +1,61 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.cards.decks.DeckCardLists; +import mage.MageException; +import mage.game.GameException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SubmitDeck extends RemoteMethodCall { + + private UUID tableId; + private UUID sessionId; + private DeckCardLists deckList; + + public SubmitDeck(Connection connection, UUID sessionId, UUID tableId, DeckCardLists deckList) { + super(connection); + this.tableId = tableId; + this.sessionId = sessionId; + this.deckList = deckList; + } + + @Override + protected Boolean performRemoteCall(Server server) throws MageException, GameException, RemoteException { + return server.submitDeck(sessionId, tableId, deckList); + } + +} diff --git a/Mage.Common/src/mage/remote/method/SwapSeats.java b/Mage.Common/src/mage/remote/method/SwapSeats.java new file mode 100644 index 00000000000..206b1322186 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/SwapSeats.java @@ -0,0 +1,64 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SwapSeats extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + private int seat1; + private int seat2; + + public SwapSeats(Connection connection, UUID sessionId, UUID roomId, UUID tableId, int seat1, int seat2) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + this.seat1 = seat1; + this.seat2 = seat2; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.swapSeats(sessionId, roomId, tableId, seat1, seat2); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/WatchGame.java b/Mage.Common/src/mage/remote/method/WatchGame.java new file mode 100644 index 00000000000..cfcd75b3e0f --- /dev/null +++ b/Mage.Common/src/mage/remote/method/WatchGame.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class WatchGame extends RemoteMethodCall { + + private UUID gameId; + private UUID sessionId; + + public WatchGame(Connection connection, UUID sessionId, UUID gameId) { + super(connection); + this.gameId = gameId; + this.sessionId = sessionId; + } + + @Override + protected Void performRemoteCall(Server server) throws RemoteException, MageException { + server.watchGame(gameId, sessionId); + return null; + } + +} diff --git a/Mage.Common/src/mage/remote/method/WatchTable.java b/Mage.Common/src/mage/remote/method/WatchTable.java new file mode 100644 index 00000000000..5446507d9b0 --- /dev/null +++ b/Mage.Common/src/mage/remote/method/WatchTable.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.remote.method; + +import java.rmi.RemoteException; +import java.util.UUID; +import mage.MageException; +import mage.interfaces.Server; +import mage.remote.Connection; +import mage.remote.RemoteMethodCall; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class WatchTable extends RemoteMethodCall { + + private UUID roomId; + private UUID tableId; + private UUID sessionId; + + public WatchTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) { + super(connection); + this.roomId = roomId; + this.tableId = tableId; + this.sessionId = sessionId; + } + + @Override + protected Boolean performRemoteCall(Server server) throws RemoteException, MageException { + return server.watchTable(sessionId, roomId, tableId); + } + +} diff --git a/Mage.Server.Console/src/main/java/mage/server/console/remote/Session.java b/Mage.Server.Console/src/main/java/mage/server/console/remote/Session.java index 847638bb7c5..7f2f4fa7066 100644 --- a/Mage.Server.Console/src/main/java/mage/server/console/remote/Session.java +++ b/Mage.Server.Console/src/main/java/mage/server/console/remote/Session.java @@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit; import javax.swing.JOptionPane; import mage.cards.decks.DeckCardLists; import mage.game.GameException; -import mage.interfaces.MageException; +import mage.MageException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; import mage.interfaces.Server; @@ -74,11 +74,11 @@ public class Session { public Session(ConsoleFrame frame) { this.frame = frame; } - public boolean connect(String password, String serverName, int port) { + public synchronized boolean connect(String password, String serverName, int port) { return connect(password, serverName, port, "", 0); } - public boolean connect(String password, String serverName, int port, String proxyServer, int proxyPort) { + public synchronized boolean connect(String password, String serverName, int port, String proxyServer, int proxyPort) { if (isConnected()) { disconnect(); } @@ -117,7 +117,7 @@ public class Session { return false; } - public void disconnect() { + public synchronized void disconnect() { if (isConnected()) { try { @@ -141,15 +141,15 @@ public class Session { JOptionPane.showMessageDialog(frame, "Disconnected.", "Disconnected", JOptionPane.INFORMATION_MESSAGE); } - public void ack(String message) { - try { - server.ack(message, sessionId); - } catch (RemoteException ex) { - handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); - } - } +// public void ack(int messageId) { +// try { +// server.ack(messageId, sessionId); +// } catch (RemoteException ex) { +// handleRemoteException(ex); +// } catch (MageException ex) { +// handleMageException(ex); +// } +// } public boolean ping() { try { @@ -260,10 +260,10 @@ public class Session { return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList); } catch (RemoteException ex) { handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); } catch (GameException ex) { handleGameException(ex); + } catch (MageException ex) { + handleMageException(ex); } return false; } @@ -273,10 +273,10 @@ public class Session { return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill); } catch (RemoteException ex) { handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); } catch (GameException ex) { handleGameException(ex); + } catch (MageException ex) { + handleMageException(ex); } return false; } @@ -569,10 +569,10 @@ public class Session { return server.submitDeck(sessionId, tableId, deck); } catch (RemoteException ex) { handleRemoteException(ex); - } catch (MageException ex) { - handleMageException(ex); } catch (GameException ex) { handleGameException(ex); + } catch (MageException ex) { + handleMageException(ex); } return false; } diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java index dc003496b83..964911a8c08 100644 --- a/Mage.Server/src/main/java/mage/server/ChatSession.java +++ b/Mage.Server/src/main/java/mage/server/ChatSession.java @@ -34,6 +34,8 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import mage.MageException; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.view.ChatMessage; import mage.view.ChatMessage.MessageColor; @@ -78,7 +80,11 @@ public class ChatSession { for (UUID sessionId: clients.keySet()) { Session session = SessionManager.getInstance().getSession(sessionId); if (session != null) - session.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(msg, color))); + try { + session.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(msg, color))); + } catch (CallbackException ex) { + logger.fatal("broadcast error", ex); + } else kill(sessionId); } diff --git a/Mage.Server/src/main/java/mage/server/ServerImpl.java b/Mage.Server/src/main/java/mage/server/ServerImpl.java index 8eff2ebce0a..4d138babd35 100644 --- a/Mage.Server/src/main/java/mage/server/ServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/ServerImpl.java @@ -38,13 +38,15 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutorService; +import java.util.logging.Level; import mage.cards.decks.DeckCardLists; import mage.game.GameException; -import mage.interfaces.MageException; +import mage.MageException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; import mage.interfaces.Server; import mage.interfaces.ServerState; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.server.game.DeckValidatorFactory; import mage.server.draft.DraftManager; @@ -105,8 +107,8 @@ public class ServerImpl extends RemoteServer implements Server { } @Override - public void ack(String message, UUID sessionId) throws RemoteException, MageException { - SessionManager.getInstance().getSession(sessionId).ack(message); + public void ack(int messageId, UUID sessionId) throws RemoteException, CallbackException { + SessionManager.getInstance().getSession(sessionId).ack(messageId); } @Override @@ -209,9 +211,10 @@ public class ServerImpl extends RemoteServer implements Server { return ret; } } + catch (GameException ex) { + throw ex; + } catch (Exception ex) { - if (ex instanceof GameException) - throw (GameException)ex; handleException(ex); } return false; @@ -226,9 +229,10 @@ public class ServerImpl extends RemoteServer implements Server { return ret; } } + catch (GameException ex) { + throw ex; + } catch (Exception ex) { - if (ex instanceof GameException) - throw (GameException)ex; handleException(ex); } return false; diff --git a/Mage.Server/src/main/java/mage/server/Session.java b/Mage.Server/src/main/java/mage/server/Session.java index feb81ba83ed..0f6796a482f 100644 --- a/Mage.Server/src/main/java/mage/server/Session.java +++ b/Mage.Server/src/main/java/mage/server/Session.java @@ -30,7 +30,12 @@ package mage.server; import java.util.Date; import java.util.UUID; +import java.util.logging.Level; import mage.cards.decks.Deck; +import mage.game.GameException; +import mage.MageException; +import mage.interfaces.callback.CallbackAck; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.CallbackServerSession; import mage.interfaces.callback.ClientCallback; import mage.server.game.GameManager; @@ -50,11 +55,12 @@ public class Session { private String username; private String host; private int messageId = 0; - private String ackMessage; private Date timeConnected; private long lastPing; private boolean isAdmin = false; + private boolean killed = false; private final CallbackServerSession callback = new CallbackServerSession(); + private final CallbackAck ackResponse = new CallbackAck(); public Session(String userName, String host, UUID clientId) { sessionId = UUID.randomUUID(); @@ -84,6 +90,8 @@ public class Session { } public void kill() { + this.killed = true; + ackResponse.notify(); SessionManager.getInstance().removeSession(sessionId); TableManager.getInstance().removeSession(sessionId); GameManager.getInstance().removeSession(sessionId); @@ -99,55 +107,116 @@ public class Session { return null; } - public synchronized void fireCallback(final ClientCallback call) { + public synchronized void fireCallback(final ClientCallback call) throws CallbackException { call.setMessageId(messageId++); if (logger.isDebugEnabled()) logger.debug(sessionId + " - " + call.getMessageId() + " - " + call.getMethod()); try { - callback.setCallback(call); + int retryCount = 0; + while (retryCount < 3) { + callback.setCallback(call); + if (waitForAck(call.getMessageId())) + return; + retryCount++; + try { + Thread.sleep(2000 * retryCount); + } + catch (InterruptedException ignored) {} + } } catch (InterruptedException ex) { logger.fatal("Session fireCallback error", ex); } + throw new CallbackException("Callback failed for " + call.getMethod()); + } + + protected boolean waitForAck(int messageId) { + ackResponse.clear(); + if (logger.isDebugEnabled()) + logger.debug(sessionId + " - waiting for ack: " + messageId); + synchronized(ackResponse) { + try { + if (!ackResponse.isAck()) + ackResponse.wait(10000); + if (logger.isDebugEnabled()) { + if (!ackResponse.isAck()) + logger.debug(sessionId + " - ack timed out waiting for " + messageId); + else + logger.debug(sessionId + " - ack received: " + messageId); + } + return ackResponse.getValue() == messageId; + } catch (InterruptedException ex) { } + } + return false; } - public void gameStarted(final UUID gameId, final UUID playerId) { - fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId))); + public void gameStarted(final UUID gameId, final UUID playerId) throws GameException { + try { + fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId))); + } catch (CallbackException ex) { + logger.fatal("gameStarted exception", ex); + throw new GameException("callback failed"); + } } - public void draftStarted(final UUID draftId, final UUID playerId) { - fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId))); + public void draftStarted(final UUID draftId, final UUID playerId) throws MageException { + try { + fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId))); + } catch (CallbackException ex) { + logger.fatal("draftStarted exception", ex); + throw new MageException("callback failed"); + } } - public void tournamentStarted(final UUID tournamentId, final UUID playerId) { - fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId))); + public void tournamentStarted(final UUID tournamentId, final UUID playerId) throws MageException { + try { + fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId))); + } catch (CallbackException ex) { + logger.fatal("tournamentStarted exception", ex); + throw new MageException("callback failed"); + } } - public void sideboard(final Deck deck, final UUID tableId, final int time) { - fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time))); + public void sideboard(final Deck deck, final UUID tableId, final int time) throws MageException { + try { + fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time))); + } catch (CallbackException ex) { + logger.fatal("sideboard exception", ex); + throw new MageException("callback failed"); + } } - public void construct(final Deck deck, final UUID tableId, final int time) { - fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time))); + public void construct(final Deck deck, final UUID tableId, final int time) throws MageException { + try { + fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time))); + } catch (CallbackException ex) { + logger.fatal("construct exception", ex); + throw new MageException("callback failed"); + } } - public void watchGame(final UUID gameId) { - fireCallback(new ClientCallback("watchGame", gameId)); + public void watchGame(final UUID gameId) throws MageException { + try { + fireCallback(new ClientCallback("watchGame", gameId)); + } catch (CallbackException ex) { + logger.fatal("watchGame exception", ex); + throw new MageException("callback failed"); + } } public void replayGame(final UUID gameId) { - fireCallback(new ClientCallback("replayGame", gameId)); + try { + fireCallback(new ClientCallback("replayGame", gameId)); + } catch (CallbackException ex) { + logger.fatal("replayGame exception", ex); + } } - public void ack(String message) { - this.ackMessage = message; - } - - public String getAckMessage() { - return ackMessage; - } - - public void clearAck() { - this.ackMessage = ""; + public void ack(int messageId) { + synchronized(ackResponse) { + ackResponse.setAck(true); + ackResponse.setValue(messageId); + ackResponse.notify(); + } } public String getUsername() { diff --git a/Mage.Server/src/main/java/mage/server/SessionManager.java b/Mage.Server/src/main/java/mage/server/SessionManager.java index ae2b8601f0b..4ab3cb4ac95 100644 --- a/Mage.Server/src/main/java/mage/server/SessionManager.java +++ b/Mage.Server/src/main/java/mage/server/SessionManager.java @@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import mage.interfaces.MageException; +import mage.MageException; import mage.view.UserView; import org.apache.log4j.Logger; @@ -97,6 +97,7 @@ public class SessionManager { } public void checkSessions() { + logger.info("Checking sessions"); for (Session session: sessions.values()) { if (!session.stillAlive()) { logger.info("Client for user " + session.getUsername() + ":" + session.getId() + " timed out - releasing resources"); diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index be56f30b562..2f7ea01c880 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -28,6 +28,7 @@ package mage.server; +import java.util.logging.Level; import mage.Constants.RangeOfInfluence; import mage.Constants.TableState; import mage.cards.decks.Deck; @@ -44,6 +45,7 @@ import mage.game.match.Match; import mage.game.match.MatchOptions; import mage.game.tournament.Tournament; import mage.game.tournament.TournamentOptions; +import mage.MageException; import mage.players.Player; import mage.server.challenge.ChallengeManager; import mage.server.draft.DraftManager; @@ -104,13 +106,17 @@ public class TableController { new Listener () { @Override public void event(TableEvent event) { - switch (event.getEventType()) { - case SIDEBOARD: - sideboard(event.getPlayerId(), event.getDeck(), event.getTimeout()); - break; - case SUBMIT_DECK: - submitDeck(event.getPlayerId(), event.getDeck()); - break; + try { + switch (event.getEventType()) { + case SIDEBOARD: + sideboard(event.getPlayerId(), event.getDeck(), event.getTimeout()); + break; + case SUBMIT_DECK: + submitDeck(event.getPlayerId(), event.getDeck()); + break; + } + } catch (MageException ex) { + logger.fatal("Table event listener error", ex); } } } @@ -202,8 +208,13 @@ public class TableController { if (table.getState() != TableState.DUELING) { return false; } - SessionManager.getInstance().getSession(sessionId).watchGame(match.getGame().getId()); - return true; + try { + SessionManager.getInstance().getSession(sessionId).watchGame(match.getGame().getId()); + return true; + } catch (MageException ex) { + logger.fatal("watchTable error", ex); + } + return false; } public boolean replayTable(UUID sessionId) { @@ -312,26 +323,37 @@ public class TableController { } public synchronized void startTournament(UUID sessionId) { - if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) { - TournamentManager.getInstance().createTournamentSession(tournament, sessionPlayerMap, table.getId()); - SessionManager sessionManager = SessionManager.getInstance(); - for (Entry entry: sessionPlayerMap.entrySet()) { - Session session = sessionManager.getSession(entry.getKey()); - session.tournamentStarted(tournament.getId(), entry.getValue()); + try { + if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) { + TournamentManager.getInstance().createTournamentSession(tournament, sessionPlayerMap, table.getId()); + SessionManager sessionManager = SessionManager.getInstance(); + for (Entry entry: sessionPlayerMap.entrySet()) { + Session session = sessionManager.getSession(entry.getKey()); + session.tournamentStarted(tournament.getId(), entry.getValue()); + } } } + catch (Exception ex) { + logger.fatal("Error starting tournament", ex); + TableManager.getInstance().removeTable(table.getId()); + TournamentManager.getInstance().kill(tournament.getId(), sessionId); + } } public void startDraft(Draft draft) { table.initDraft(); DraftManager.getInstance().createDraftSession(draft, sessionPlayerMap, table.getId()); SessionManager sessionManager = SessionManager.getInstance(); - for (Entry entry: sessionPlayerMap.entrySet()) { - sessionManager.getSession(entry.getKey()).draftStarted(draft.getId(), entry.getValue()); + try { + for (Entry entry: sessionPlayerMap.entrySet()) { + sessionManager.getSession(entry.getKey()).draftStarted(draft.getId(), entry.getValue()); + } + } catch (MageException ex) { + logger.fatal("startDraft error", ex); } } - private void sideboard(UUID playerId, Deck deck, int timeout) { + private void sideboard(UUID playerId, Deck deck, int timeout) throws MageException { SessionManager sessionManager = SessionManager.getInstance(); for (Entry entry: sessionPlayerMap.entrySet()) { if (entry.getValue().equals(playerId)) { diff --git a/Mage.Server/src/main/java/mage/server/TableManager.java b/Mage.Server/src/main/java/mage/server/TableManager.java index 2290a8d2e6f..048c8db729c 100644 --- a/Mage.Server/src/main/java/mage/server/TableManager.java +++ b/Mage.Server/src/main/java/mage/server/TableManager.java @@ -39,6 +39,7 @@ import mage.game.draft.Draft; import mage.game.match.Match; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; +import mage.MageException; import mage.players.Player; import mage.server.game.GamesRoomManager; import org.apache.log4j.Logger; diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftController.java b/Mage.Server/src/main/java/mage/server/draft/DraftController.java index 7afd8259e8a..ac721951247 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftController.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftController.java @@ -38,6 +38,7 @@ import mage.game.draft.DraftPlayer; import mage.game.events.Listener; import mage.game.events.PlayerQueryEvent; import mage.game.events.TableEvent; +import mage.MageException; import mage.server.game.GameController; import mage.server.TableManager; import mage.server.util.ThreadExecutor; @@ -73,13 +74,18 @@ public class DraftController { new Listener () { @Override public void event(TableEvent event) { - switch (event.getEventType()) { - case UPDATE: - updateDraft(); - break; - case END: - endDraft(); - break; + try { + switch (event.getEventType()) { + case UPDATE: + updateDraft(); + break; + case END: + endDraft(); + break; + } + } + catch (MageException ex) { + logger.fatal("Table event listener error", ex); } } } @@ -88,10 +94,15 @@ public class DraftController { new Listener () { @Override public void event(PlayerQueryEvent event) { - switch (event.getQueryType()) { - case PICK_CARD: - pickCard(event.getPlayerId(), event.getMax()); - break; + try { + switch (event.getQueryType()) { + case PICK_CARD: + pickCard(event.getPlayerId(), event.getMax()); + break; + } + } + catch (MageException ex) { + logger.fatal("Table event listener error", ex); } } } @@ -156,7 +167,7 @@ public class DraftController { draft.leave(getPlayerId(sessionId)); } - private void endDraft() { + private void endDraft() throws MageException { for (final DraftSession draftSession: draftSessions.values()) { draftSession.draftOver(); } @@ -189,13 +200,13 @@ public class DraftController { return null; } - private synchronized void updateDraft() { + private synchronized void updateDraft() throws MageException { for (final Entry entry: draftSessions.entrySet()) { entry.getValue().update(getDraftView()); } } - private synchronized void pickCard(UUID playerId, int timeout) { + private synchronized void pickCard(UUID playerId, int timeout) throws MageException { if (draftSessions.containsKey(playerId)) draftSessions.get(playerId).pickCard(getDraftPickView(playerId, timeout), timeout); } diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftSession.java b/Mage.Server/src/main/java/mage/server/draft/DraftSession.java index 84d19abc1f3..7d2630ab5bb 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftSession.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftSession.java @@ -33,7 +33,10 @@ import java.util.UUID; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import mage.game.draft.Draft; +import mage.MageException; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.server.Session; import mage.server.SessionManager; @@ -69,44 +72,62 @@ public class DraftSession { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); if (session != null) { - session.clearAck(); - session.fireCallback(new ClientCallback("draftInit", draft.getId(), draftView)); - if (waitForAck("draftInit")) + try { + session.fireCallback(new ClientCallback("draftInit", draft.getId(), draftView)); return true; + } catch (CallbackException ex) { + logger.fatal("Unable to start draft ", ex); + return false; + } } } return false; } - public boolean waitForAck(String message) { - Session session = SessionManager.getInstance().getSession(sessionId); - do { - //TODO: add timeout - } while (!session.getAckMessage().equals(message) && !killed); - return true; - } +// public boolean waitForAck(String message) { +// Session session = SessionManager.getInstance().getSession(sessionId); +// do { +// //TODO: add timeout +// } while (!session.getAckMessage().equals(message) && !killed); +// return true; +// } public void update(final DraftView draftView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("draftUpdate", draft.getId(), draftView)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("draftUpdate", draft.getId(), draftView)); + } catch (CallbackException ex) { + logger.fatal("update draft exception", ex); + } + } } } public void inform(final String message, final DraftView draftView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(draftView, message))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(draftView, message))); + } catch (CallbackException ex) { + logger.fatal("draft inform exception", ex); + } + } } } public void draftOver() { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("draftOver", draft.getId())); + if (session != null) { + try { + session.fireCallback(new ClientCallback("draftOver", draft.getId())); + } catch (CallbackException ex) { + logger.fatal("draft end exception", ex); + } + } } } @@ -114,8 +135,13 @@ public class DraftSession { if (!killed) { setupTimeout(timeout); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(draftPickView))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(draftPickView))); + } catch (CallbackException ex) { + logger.fatal("draft pick exception", ex); + } + } } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameCallback.java b/Mage.Server/src/main/java/mage/server/game/GameCallback.java index 49cccafbf1a..f686545c343 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameCallback.java +++ b/Mage.Server/src/main/java/mage/server/game/GameCallback.java @@ -28,12 +28,14 @@ package mage.server.game; +import mage.MageException; + /** * * @author BetaSteward_at_googlemail.com */ public interface GameCallback { - public void gameResult(String result); + public void gameResult(String result) throws MageException; } diff --git a/Mage.Server/src/main/java/mage/server/game/GameController.java b/Mage.Server/src/main/java/mage/server/game/GameController.java index 4ed2af76fa2..30b94868b8e 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameController.java +++ b/Mage.Server/src/main/java/mage/server/game/GameController.java @@ -29,8 +29,10 @@ package mage.server.game; import java.io.BufferedOutputStream; +import java.util.logging.Level; import mage.game.LookedAt; +import mage.MageException; import mage.server.TableManager; import java.io.File; import java.io.FileOutputStream; @@ -103,17 +105,21 @@ public class GameController implements GameCallback { new Listener () { @Override public void event(TableEvent event) { - switch (event.getEventType()) { - case UPDATE: - updateGame(); - break; - case INFO: - ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK); - logger.debug(game.getId() + " " + event.getMessage()); - break; - case REVEAL: - revealCards(event.getMessage(), event.getCards()); - break; + try { + switch (event.getEventType()) { + case UPDATE: + updateGame(); + break; + case INFO: + ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK); + logger.debug(game.getId() + " " + event.getMessage()); + break; + case REVEAL: + revealCards(event.getMessage(), event.getCards()); + break; + } + } catch (MageException ex) { + logger.fatal("Table event listener error ", ex); } } } @@ -123,37 +129,41 @@ public class GameController implements GameCallback { @Override public void event(PlayerQueryEvent event) { // logger.info(event.getPlayerId() + "--" + event.getQueryType() + "--" + event.getMessage()); - switch (event.getQueryType()) { - case ASK: - ask(event.getPlayerId(), event.getMessage()); - break; - case PICK_TARGET: - target(event.getPlayerId(), event.getMessage(), event.getCards(), event.getTargets(), event.isRequired(), event.getOptions()); - break; - case PICK_ABILITY: - target(event.getPlayerId(), event.getMessage(), event.getAbilities(), event.isRequired(), event.getOptions()); - break; - case SELECT: - select(event.getPlayerId(), event.getMessage()); - break; - case PLAY_MANA: - playMana(event.getPlayerId(), event.getMessage()); - break; - case PLAY_X_MANA: - playXMana(event.getPlayerId(), event.getMessage()); - break; - case CHOOSE_ABILITY: - chooseAbility(event.getPlayerId(), event.getAbilities()); - break; - case CHOOSE: - choose(event.getPlayerId(), event.getMessage(), event.getChoices()); - break; - case AMOUNT: - amount(event.getPlayerId(), event.getMessage(), event.getMin(), event.getMax()); - break; - case LOOK: - lookAtCards(event.getPlayerId(), event.getMessage(), event.getCards()); - break; + try { + switch (event.getQueryType()) { + case ASK: + ask(event.getPlayerId(), event.getMessage()); + break; + case PICK_TARGET: + target(event.getPlayerId(), event.getMessage(), event.getCards(), event.getTargets(), event.isRequired(), event.getOptions()); + break; + case PICK_ABILITY: + target(event.getPlayerId(), event.getMessage(), event.getAbilities(), event.isRequired(), event.getOptions()); + break; + case SELECT: + select(event.getPlayerId(), event.getMessage()); + break; + case PLAY_MANA: + playMana(event.getPlayerId(), event.getMessage()); + break; + case PLAY_X_MANA: + playXMana(event.getPlayerId(), event.getMessage()); + break; + case CHOOSE_ABILITY: + chooseAbility(event.getPlayerId(), event.getAbilities()); + break; + case CHOOSE: + choose(event.getPlayerId(), event.getMessage(), event.getChoices()); + break; + case AMOUNT: + amount(event.getPlayerId(), event.getMessage(), event.getMin(), event.getMax()); + break; + case LOOK: + lookAtCards(event.getPlayerId(), event.getMessage(), event.getCards()); + break; + } + } catch (MageException ex) { + logger.fatal("Player event listener error ", ex); } } } @@ -282,7 +292,7 @@ public class GameController implements GameCallback { } } - public void endGame(final String message) { + public void endGame(final String message) throws MageException { for (final GameSession gameSession: gameSessions.values()) { gameSession.gameOver(message); } @@ -317,7 +327,6 @@ public class GameController implements GameCallback { } private synchronized void updateGame() { - for (final Entry entry: gameSessions.entrySet()) { entry.getValue().update(getGameView(entry.getKey())); } @@ -326,25 +335,25 @@ public class GameController implements GameCallback { } } - private synchronized void ask(UUID playerId, String question) { + private synchronized void ask(UUID playerId, String question) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).ask(question, getGameView(playerId)); informOthers(playerId); } - private synchronized void chooseAbility(UUID playerId, Collection choices) { + private synchronized void chooseAbility(UUID playerId, Collection choices) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).chooseAbility(new AbilityPickerView(choices)); informOthers(playerId); } - private synchronized void choose(UUID playerId, String message, Set choices) { + private synchronized void choose(UUID playerId, String message, Set choices) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).choose(message, choices); informOthers(playerId); } - private synchronized void target(UUID playerId, String question, Cards cards, Set targets, boolean required, Map options) { + private synchronized void target(UUID playerId, String question, Cards cards, Set targets, boolean required, Map options) throws MageException { if (gameSessions.containsKey(playerId)) { if (cards != null) gameSessions.get(playerId).target(question, new CardsView(cards.getCards(game)), targets, required, getGameView(playerId), options); @@ -354,48 +363,48 @@ public class GameController implements GameCallback { informOthers(playerId); } - private synchronized void target(UUID playerId, String question, Collection abilities, boolean required, Map options) { + private synchronized void target(UUID playerId, String question, Collection abilities, boolean required, Map options) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).target(question, new CardsView(abilities, game), null, required, getGameView(playerId), options); informOthers(playerId); } - private synchronized void select(UUID playerId, String message) { + private synchronized void select(UUID playerId, String message) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).select(message, getGameView(playerId)); informOthers(playerId); } - private synchronized void playMana(UUID playerId, String message) { + private synchronized void playMana(UUID playerId, String message) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).playMana(message, getGameView(playerId)); informOthers(playerId); } - private synchronized void playXMana(UUID playerId, String message) { + private synchronized void playXMana(UUID playerId, String message) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).playXMana(message, getGameView(playerId)); informOthers(playerId); } - private synchronized void amount(UUID playerId, String message, int min, int max) { + private synchronized void amount(UUID playerId, String message, int min, int max) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).getAmount(message, min, max); informOthers(playerId); } - private synchronized void revealCards(String name, Cards cards) { + private synchronized void revealCards(String name, Cards cards) throws MageException { for (GameSession session: gameSessions.values()) { session.revealCards(name, new CardsView(cards.getCards(game))); } } - private synchronized void lookAtCards(UUID playerId, String name, Cards cards) { + private synchronized void lookAtCards(UUID playerId, String name, Cards cards) throws MageException { if (gameSessions.containsKey(playerId)) gameSessions.get(playerId).revealCards(name, new CardsView(cards.getCards(game))); } - private void informOthers(UUID playerId) { + private void informOthers(UUID playerId) throws MageException { final String message = "Waiting for " + game.getPlayer(playerId).getName(); for (final Entry entry: gameSessions.entrySet()) { if (!entry.getKey().equals(playerId)) { @@ -426,7 +435,11 @@ public class GameController implements GameCallback { @Override public void gameResult(String result) { - endGame(result); + try { + endGame(result); + } catch (MageException ex) { + logger.fatal("Game Result error", ex); + } } public void saveGame() { diff --git a/Mage.Server/src/main/java/mage/server/game/GameManager.java b/Mage.Server/src/main/java/mage/server/game/GameManager.java index b7ea82341b3..661031c7bbb 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameManager.java +++ b/Mage.Server/src/main/java/mage/server/game/GameManager.java @@ -32,6 +32,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import mage.cards.decks.DeckCardLists; import mage.game.Game; +import mage.MageException; import mage.view.GameView; /** diff --git a/Mage.Server/src/main/java/mage/server/game/GameSession.java b/Mage.Server/src/main/java/mage/server/game/GameSession.java index 526d3a4ee33..550bbcc832d 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameSession.java +++ b/Mage.Server/src/main/java/mage/server/game/GameSession.java @@ -36,6 +36,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import mage.game.Game; +import mage.MageException; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.server.Session; import mage.server.SessionManager; @@ -64,12 +66,17 @@ public class GameSession extends GameWatcher { this.playerId = playerId; } - public void ask(final String question, final GameView gameView) { + public void ask(final String question, final GameView gameView) { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(gameView, question))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(gameView, question))); + } catch (CallbackException ex) { + logger.fatal("game ask exception", ex); + } + } } } @@ -77,8 +84,13 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(gameView, question, cardView, targets, required, options))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(gameView, question, cardView, targets, required, options))); + } catch (CallbackException ex) { + logger.fatal("game target exception", ex); + } + } } } @@ -86,8 +98,13 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(gameView, message))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(gameView, message))); + } catch (CallbackException ex) { + logger.fatal("game select exception", ex); + } + } } } @@ -95,8 +112,13 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities)); + } catch (CallbackException ex) { + logger.fatal("game choose ability exception", ex); + } + } } } @@ -104,8 +126,13 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[0]), message))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[0]), message))); + } catch (CallbackException ex) { + logger.fatal("game choose exception", ex); + } + } } } @@ -113,8 +140,13 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(gameView, message))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(gameView, message))); + } catch (CallbackException ex) { + logger.fatal("game play mana exception", ex); + } + } } } @@ -122,8 +154,13 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(gameView, message))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(gameView, message))); + } catch (CallbackException ex) { + logger.fatal("game play x mana exception", ex); + } + } } } @@ -131,16 +168,26 @@ public class GameSession extends GameWatcher { if (!killed) { setupTimeout(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max))); + } catch (CallbackException ex) { + logger.fatal("game select amount exception", ex); + } + } } } public void revealCards(final String name, final CardsView cardView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name))); + } catch (CallbackException ex) { + logger.fatal("game reveal exception", ex); + } + } } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameWatcher.java b/Mage.Server/src/main/java/mage/server/game/GameWatcher.java index 6913e690cd7..3fd5bbd08ec 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameWatcher.java +++ b/Mage.Server/src/main/java/mage/server/game/GameWatcher.java @@ -30,6 +30,9 @@ package mage.server.game; import java.rmi.RemoteException; import java.util.UUID; +import java.util.logging.Level; +import mage.MageException; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.server.Session; import mage.server.SessionManager; @@ -58,44 +61,54 @@ public class GameWatcher { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); if (session != null) { - session.clearAck(); - session.fireCallback(new ClientCallback("gameInit", gameId, gameView)); - if (waitForAck("gameInit")) + try { + session.fireCallback(new ClientCallback("gameInit", gameId, gameView)); return true; + } catch (CallbackException ex) { + logger.fatal("Unable to start watching ", ex); + return false; + } } } return false; } - public boolean waitForAck(String message) { - Session session = SessionManager.getInstance().getSession(sessionId); - do { - //TODO: add timeout - } while (!session.getAckMessage().equals(message) && !killed); - return true; - } - public void update(final GameView gameView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameUpdate", gameId, gameView)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameUpdate", gameId, gameView)); + } catch (CallbackException ex) { + logger.fatal("game update exception", ex); + } + } } } public void inform(final String message, final GameView gameView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameInform", gameId, new GameClientMessage(gameView, message))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameInform", gameId, new GameClientMessage(gameView, message))); + } catch (CallbackException ex) { + logger.fatal("game inform exception", ex); + } + } } } public void gameOver(final String message) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("gameOver", gameId, message)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("gameOver", gameId, message)); + } catch (CallbackException ex) { + logger.fatal("game select exception", ex); + } + } } } diff --git a/Mage.Server/src/main/java/mage/server/game/GameWorker.java b/Mage.Server/src/main/java/mage/server/game/GameWorker.java index 5abee8b2be4..1ca68e28044 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameWorker.java +++ b/Mage.Server/src/main/java/mage/server/game/GameWorker.java @@ -58,7 +58,6 @@ public class GameWorker implements Callable { result.gameResult(game.getWinner()); } catch (Exception ex) { logger.fatal("GameWorker error ", ex); - result.gameResult("Server Error"); } return null; } diff --git a/Mage.Server/src/main/java/mage/server/game/GamesRoom.java b/Mage.Server/src/main/java/mage/server/game/GamesRoom.java index a43d1a35857..0785a83b780 100644 --- a/Mage.Server/src/main/java/mage/server/game/GamesRoom.java +++ b/Mage.Server/src/main/java/mage/server/game/GamesRoom.java @@ -35,6 +35,7 @@ import mage.cards.decks.DeckCardLists; import mage.game.GameException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; +import mage.MageException; import mage.view.TableView; /** @@ -52,6 +53,6 @@ public interface GamesRoom extends Room { public void removeTable(UUID tableId); public TableView getTable(UUID tableId); public void leaveTable(UUID sessionId, UUID tableId); - public boolean watchTable(UUID sessionId, UUID tableId); + public boolean watchTable(UUID sessionId, UUID tableId) throws MageException; } diff --git a/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java b/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java index 0b1ff934ec2..881328a0a8a 100644 --- a/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java +++ b/Mage.Server/src/main/java/mage/server/game/GamesRoomImpl.java @@ -40,6 +40,7 @@ import mage.cards.decks.DeckCardLists; import mage.game.GameException; import mage.game.match.MatchOptions; import mage.game.tournament.TournamentOptions; +import mage.MageException; import mage.view.TableView; import org.apache.log4j.Logger; @@ -119,7 +120,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable { } @Override - public boolean watchTable(UUID sessionId, UUID tableId) { + public boolean watchTable(UUID sessionId, UUID tableId) throws MageException { return TableManager.getInstance().watchTable(sessionId, tableId); } diff --git a/Mage.Server/src/main/java/mage/server/game/ReplayManager.java b/Mage.Server/src/main/java/mage/server/game/ReplayManager.java index 50adce7f7d9..a945babe0e7 100644 --- a/Mage.Server/src/main/java/mage/server/game/ReplayManager.java +++ b/Mage.Server/src/main/java/mage/server/game/ReplayManager.java @@ -30,6 +30,7 @@ package mage.server.game; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import mage.MageException; import mage.server.SessionManager; /** diff --git a/Mage.Server/src/main/java/mage/server/game/ReplaySession.java b/Mage.Server/src/main/java/mage/server/game/ReplaySession.java index 7bea4e83973..15af8d48b64 100644 --- a/Mage.Server/src/main/java/mage/server/game/ReplaySession.java +++ b/Mage.Server/src/main/java/mage/server/game/ReplaySession.java @@ -31,10 +31,13 @@ package mage.server.game; import java.util.UUID; import mage.game.Game; import mage.game.GameState; +import mage.MageException; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.server.Session; import mage.server.SessionManager; import mage.view.GameView; +import org.apache.log4j.Logger; /** * @@ -42,6 +45,7 @@ import mage.view.GameView; */ public class ReplaySession implements GameCallback { + private final static Logger logger = Logger.getLogger(ReplaySession.class); private GameReplay replay; protected UUID sessionId; @@ -53,8 +57,13 @@ public class ReplaySession implements GameCallback { public void replay() { replay.start(); Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame()))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame()))); + } catch (CallbackException ex) { + logger.fatal("replay init exception", ex); + } + } } public void stop() { @@ -72,8 +81,13 @@ public class ReplaySession implements GameCallback { @Override public void gameResult(final String result) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result)); + } catch (CallbackException ex) { + logger.fatal("replay done exception", ex); + } + } } private void updateGame(final GameState state, Game game) { @@ -82,8 +96,13 @@ public class ReplaySession implements GameCallback { } else { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game))); + if (session != null) { + try { + session.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game))); + } catch (CallbackException ex) { + logger.fatal("replay update exception", ex); + } + } } } diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java index a6badee3afd..5e8cfecec6c 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentController.java @@ -31,6 +31,7 @@ package mage.server.tournament; import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; import mage.cards.decks.Deck; import mage.game.GameException; import mage.game.Table; @@ -42,6 +43,7 @@ import mage.game.match.MatchOptions; import mage.game.tournament.Tournament; import mage.game.tournament.TournamentPairing; import mage.game.tournament.TournamentPlayer; +import mage.MageException; import mage.server.ChatManager; import mage.server.TableManager; import mage.server.game.GamesRoomManager; @@ -104,10 +106,14 @@ public class TournamentController { new Listener () { @Override public void event(PlayerQueryEvent event) { - switch (event.getQueryType()) { - case CONSTRUCT: - construct(event.getPlayerId(), event.getDeck(), event.getMax()); - break; + try { + switch (event.getQueryType()) { + case CONSTRUCT: + construct(event.getPlayerId(), event.getDeck(), event.getMax()); + break; + } + } catch (MageException ex) { + logger.fatal("Player event listener error", ex); } } } @@ -190,7 +196,7 @@ public class TournamentController { TableManager.getInstance().construct(tableId); } - private void construct(UUID sessionId, Deck deck, int timeout) { + private void construct(UUID sessionId, Deck deck, int timeout) throws MageException { if (tournamentSessions.containsKey(sessionId)) tournamentSessions.get(sessionId).construct(deck, timeout); } diff --git a/Mage.Server/src/main/java/mage/server/tournament/TournamentSession.java b/Mage.Server/src/main/java/mage/server/tournament/TournamentSession.java index a03e5fe0ebb..68bc794437b 100644 --- a/Mage.Server/src/main/java/mage/server/tournament/TournamentSession.java +++ b/Mage.Server/src/main/java/mage/server/tournament/TournamentSession.java @@ -33,8 +33,11 @@ import java.util.UUID; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import mage.cards.decks.Deck; import mage.game.tournament.Tournament; +import mage.MageException; +import mage.interfaces.callback.CallbackException; import mage.interfaces.callback.ClientCallback; import mage.server.Session; import mage.server.SessionManager; @@ -69,40 +72,52 @@ public class TournamentSession { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); if (session != null) { - session.clearAck(); - session.fireCallback(new ClientCallback("tournamentInit", tournament.getId(), tournamentView)); - if (waitForAck("tournamentInit")) + try { + session.fireCallback(new ClientCallback("tournamentInit", tournament.getId(), tournamentView)); return true; + } catch (CallbackException ex) { + logger.fatal("Unable to start tournament", ex); + } } } return false; } - public boolean waitForAck(String message) { - Session session = SessionManager.getInstance().getSession(sessionId); - do { - //TODO: add timeout - } while (!session.getAckMessage().equals(message) && !killed); - return true; - } +// public boolean waitForAck(String message) { +// Session session = SessionManager.getInstance().getSession(sessionId); +// do { +// //TODO: add timeout +// } while (!session.getAckMessage().equals(message) && !killed); +// return true; +// } public void update(final TournamentView tournamentView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("tournamentUpdate", tournament.getId(), tournamentView)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("tournamentUpdate", tournament.getId(), tournamentView)); + } catch (CallbackException ex) { + logger.fatal("tournament update error", ex); + } + } } } public void gameOver(final String message) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) - session.fireCallback(new ClientCallback("tournamentOver", tournament.getId(), message)); + if (session != null) { + try { + session.fireCallback(new ClientCallback("tournamentOver", tournament.getId(), message)); + } catch (CallbackException ex) { + logger.fatal("tournament over error", ex); + } + } } } - public void construct(Deck deck, int timeout) { + public void construct(Deck deck, int timeout) throws MageException { if (!killed) { setupTimeout(timeout); Session session = SessionManager.getInstance().getSession(sessionId); diff --git a/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java b/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java new file mode 100644 index 00000000000..b13ad82686d --- /dev/null +++ b/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java @@ -0,0 +1,134 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.sets.zendikar; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Layer; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.SubLayer; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.cards.CardImpl; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class OracleOfMulDaya extends CardImpl { + + public OracleOfMulDaya(UUID ownerId) { + super(ownerId, 172, "Oracle of Mul Daya", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{G}"); + this.expansionSetCode = "ZEN"; + this.subtype.add("Elf"); + this.subtype.add("Shaman"); + this.color.setWhite(true); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new OracleOfMulDayaEffect1())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new OracleOfMulDayaEffect2())); + } + + public OracleOfMulDaya(final OracleOfMulDaya card) { + super(card); + } + + @Override + public OracleOfMulDaya copy() { + return new OracleOfMulDaya(this); + } + +} + +class OracleOfMulDayaEffect1 extends ContinuousEffectImpl { + + public OracleOfMulDayaEffect1() { + super(Duration.WhileOnBattlefield, Layer.PlayerEffects, SubLayer.NA, Outcome.PutLandInPlay); + } + + public OracleOfMulDayaEffect1(final OracleOfMulDayaEffect1 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + player.setLandsPerTurn(player.getLandsPerTurn() + 1); + return true; + } + return false; + } + + @Override + public OracleOfMulDayaEffect1 copy() { + return new OracleOfMulDayaEffect1(this); + } + +} + +class OracleOfMulDayaEffect2 extends ContinuousEffectImpl { + + public OracleOfMulDayaEffect2() { + super(Duration.WhileOnBattlefield, Layer.RulesEffects, SubLayer.NA, Outcome.Neutral); + } + + public OracleOfMulDayaEffect2(final OracleOfMulDayaEffect2 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player != null) { + Cards cards = new CardsImpl(); + cards.add(player.getLibrary().getFromTop(game)); + player.revealCards(player.getName() + " top of library", cards, game); + return true; + } + return false; + } + + @Override + public OracleOfMulDayaEffect2 copy() { + return new OracleOfMulDayaEffect2(this); + } + +} \ No newline at end of file diff --git a/Mage.Common/src/mage/interfaces/MageException.java b/Mage/src/mage/MageException.java similarity index 98% rename from Mage.Common/src/mage/interfaces/MageException.java rename to Mage/src/mage/MageException.java index 202c5bae20f..8e76bee88c4 100644 --- a/Mage.Common/src/mage/interfaces/MageException.java +++ b/Mage/src/mage/MageException.java @@ -26,7 +26,7 @@ * or implied, of BetaSteward_at_googlemail.com. */ -package mage.interfaces; +package mage; /** * Root application exception. diff --git a/Mage/src/mage/game/GameException.java b/Mage/src/mage/game/GameException.java index e56753fb82f..53fb6db0499 100644 --- a/Mage/src/mage/game/GameException.java +++ b/Mage/src/mage/game/GameException.java @@ -28,11 +28,13 @@ package mage.game; +import mage.MageException; + /** * * @author BetaSteward_at_googlemail.com */ -public class GameException extends Exception { +public class GameException extends MageException { public GameException (String message) { super(message);