mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
client/server overhaul - tested on localhost, remote testing pending
This commit is contained in:
parent
ecbd843fb7
commit
892f7cce1b
90 changed files with 4448 additions and 500 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<TableView> 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<String> 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 {
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package mage.interfaces;
|
||||
|
||||
import mage.MageException;
|
||||
|
||||
/**
|
||||
* Exception thrown by plugin on errors.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
|
60
Mage.Common/src/mage/interfaces/callback/CallbackAck.java
Normal file
60
Mage.Common/src/mage/interfaces/callback/CallbackAck.java
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
102
Mage.Common/src/mage/remote/AbstractRemoteMethodCall.java
Normal file
102
Mage.Common/src/mage/remote/AbstractRemoteMethodCall.java
Normal file
|
@ -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<T, E extends Exception> {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
75
Mage.Common/src/mage/remote/AdditiveWaitRetryStrategy.java
Normal file
75
Mage.Common/src/mage/remote/AdditiveWaitRetryStrategy.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
81
Mage.Common/src/mage/remote/RemoteMethodCall.java
Normal file
81
Mage.Common/src/mage/remote/RemoteMethodCall.java
Normal file
|
@ -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<T, E extends Exception> extends AbstractRemoteMethodCall<T, E> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
51
Mage.Common/src/mage/remote/RetryException.java
Normal file
51
Mage.Common/src/mage/remote/RetryException.java
Normal file
|
@ -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 {
|
||||
}
|
||||
}
|
72
Mage.Common/src/mage/remote/RetryStrategy.java
Normal file
72
Mage.Common/src/mage/remote/RetryStrategy.java
Normal file
|
@ -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) {}
|
||||
}
|
||||
}
|
71
Mage.Common/src/mage/remote/ServerCache.java
Normal file
71
Mage.Common/src/mage/remote/ServerCache.java
Normal file
|
@ -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<Connection, Server> servers = new HashMap<Connection, Server>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
51
Mage.Common/src/mage/remote/ServerUnavailable.java
Normal file
51
Mage.Common/src/mage/remote/ServerUnavailable.java
Normal file
|
@ -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{
|
||||
}
|
||||
}
|
58
Mage.Common/src/mage/remote/method/Ack.java
Normal file
58
Mage.Common/src/mage/remote/method/Ack.java
Normal file
|
@ -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<Void, CallbackException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
56
Mage.Common/src/mage/remote/method/Callback.java
Normal file
56
Mage.Common/src/mage/remote/method/Callback.java
Normal file
|
@ -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<ClientCallback, CallbackException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
64
Mage.Common/src/mage/remote/method/Cheat.java
Normal file
64
Mage.Common/src/mage/remote/method/Cheat.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/ConcedeGame.java
Normal file
59
Mage.Common/src/mage/remote/method/ConcedeGame.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
61
Mage.Common/src/mage/remote/method/CreateTable.java
Normal file
61
Mage.Common/src/mage/remote/method/CreateTable.java
Normal file
|
@ -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<TableView, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<TableView, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
57
Mage.Common/src/mage/remote/method/DeregisterClient.java
Normal file
57
Mage.Common/src/mage/remote/method/DeregisterClient.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
57
Mage.Common/src/mage/remote/method/GetConnectedPlayers.java
Normal file
57
Mage.Common/src/mage/remote/method/GetConnectedPlayers.java
Normal file
|
@ -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<List<String>, MageException> {
|
||||
|
||||
private UUID roomId;
|
||||
|
||||
public GetConnectedPlayers(Connection connection, UUID roomId) {
|
||||
super(connection);
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getConnectedPlayers(roomId);
|
||||
}
|
||||
|
||||
}
|
56
Mage.Common/src/mage/remote/method/GetGameChatId.java
Normal file
56
Mage.Common/src/mage/remote/method/GetGameChatId.java
Normal file
|
@ -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<UUID, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
54
Mage.Common/src/mage/remote/method/GetMainRoomId.java
Normal file
54
Mage.Common/src/mage/remote/method/GetMainRoomId.java
Normal file
|
@ -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<UUID, MageException> {
|
||||
|
||||
|
||||
public GetMainRoomId(Connection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getMainRoomId();
|
||||
}
|
||||
|
||||
}
|
56
Mage.Common/src/mage/remote/method/GetRoomChatId.java
Normal file
56
Mage.Common/src/mage/remote/method/GetRoomChatId.java
Normal file
|
@ -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<UUID, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
52
Mage.Common/src/mage/remote/method/GetServerState.java
Normal file
52
Mage.Common/src/mage/remote/method/GetServerState.java
Normal file
|
@ -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<ServerState, MageException> {
|
||||
|
||||
public GetServerState(Connection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerState performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getServerState();
|
||||
}
|
||||
|
||||
}
|
58
Mage.Common/src/mage/remote/method/GetTable.java
Normal file
58
Mage.Common/src/mage/remote/method/GetTable.java
Normal file
|
@ -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<TableView, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
56
Mage.Common/src/mage/remote/method/GetTableChatId.java
Normal file
56
Mage.Common/src/mage/remote/method/GetTableChatId.java
Normal file
|
@ -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<UUID, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
58
Mage.Common/src/mage/remote/method/GetTables.java
Normal file
58
Mage.Common/src/mage/remote/method/GetTables.java
Normal file
|
@ -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<List<TableView>, MageException> {
|
||||
|
||||
private UUID roomId;
|
||||
|
||||
public GetTables(Connection connection, UUID roomId) {
|
||||
super(connection);
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TableView> performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getTables(roomId);
|
||||
}
|
||||
|
||||
}
|
56
Mage.Common/src/mage/remote/method/GetTournament.java
Normal file
56
Mage.Common/src/mage/remote/method/GetTournament.java
Normal file
|
@ -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<TournamentView, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
56
Mage.Common/src/mage/remote/method/GetTournamentChatId.java
Normal file
56
Mage.Common/src/mage/remote/method/GetTournamentChatId.java
Normal file
|
@ -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<UUID, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/IsTableOwner.java
Normal file
59
Mage.Common/src/mage/remote/method/IsTableOwner.java
Normal file
|
@ -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<Boolean, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/JoinChat.java
Normal file
60
Mage.Common/src/mage/remote/method/JoinChat.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/JoinDraft.java
Normal file
59
Mage.Common/src/mage/remote/method/JoinDraft.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/JoinGame.java
Normal file
59
Mage.Common/src/mage/remote/method/JoinGame.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
69
Mage.Common/src/mage/remote/method/JoinTable.java
Normal file
69
Mage.Common/src/mage/remote/method/JoinTable.java
Normal file
|
@ -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<Boolean, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/JoinTournament.java
Normal file
59
Mage.Common/src/mage/remote/method/JoinTournament.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
67
Mage.Common/src/mage/remote/method/JoinTournamentTable.java
Normal file
67
Mage.Common/src/mage/remote/method/JoinTournamentTable.java
Normal file
|
@ -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<Boolean, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
58
Mage.Common/src/mage/remote/method/LeaveChat.java
Normal file
58
Mage.Common/src/mage/remote/method/LeaveChat.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/LeaveTable.java
Normal file
60
Mage.Common/src/mage/remote/method/LeaveTable.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/NextPlay.java
Normal file
59
Mage.Common/src/mage/remote/method/NextPlay.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
55
Mage.Common/src/mage/remote/method/Ping.java
Normal file
55
Mage.Common/src/mage/remote/method/Ping.java
Normal file
|
@ -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<Boolean, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/PreviousPlay.java
Normal file
59
Mage.Common/src/mage/remote/method/PreviousPlay.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
61
Mage.Common/src/mage/remote/method/RegisterClient.java
Normal file
61
Mage.Common/src/mage/remote/method/RegisterClient.java
Normal file
|
@ -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<UUID, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/RemoveTable.java
Normal file
60
Mage.Common/src/mage/remote/method/RemoveTable.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/ReplayGame.java
Normal file
59
Mage.Common/src/mage/remote/method/ReplayGame.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/SendCardPick.java
Normal file
60
Mage.Common/src/mage/remote/method/SendCardPick.java
Normal file
|
@ -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<DraftPickView, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/SendChatMessage.java
Normal file
60
Mage.Common/src/mage/remote/method/SendChatMessage.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/SendPlayerBoolean.java
Normal file
60
Mage.Common/src/mage/remote/method/SendPlayerBoolean.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/SendPlayerInteger.java
Normal file
60
Mage.Common/src/mage/remote/method/SendPlayerInteger.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/SendPlayerString.java
Normal file
60
Mage.Common/src/mage/remote/method/SendPlayerString.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/SendPlayerUUID.java
Normal file
60
Mage.Common/src/mage/remote/method/SendPlayerUUID.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
62
Mage.Common/src/mage/remote/method/StartChallenge.java
Normal file
62
Mage.Common/src/mage/remote/method/StartChallenge.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/StartGame.java
Normal file
60
Mage.Common/src/mage/remote/method/StartGame.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/StartReplay.java
Normal file
59
Mage.Common/src/mage/remote/method/StartReplay.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
60
Mage.Common/src/mage/remote/method/StartTournament.java
Normal file
60
Mage.Common/src/mage/remote/method/StartTournament.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/StopReplay.java
Normal file
59
Mage.Common/src/mage/remote/method/StopReplay.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/StopWatching.java
Normal file
59
Mage.Common/src/mage/remote/method/StopWatching.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
61
Mage.Common/src/mage/remote/method/SubmitDeck.java
Normal file
61
Mage.Common/src/mage/remote/method/SubmitDeck.java
Normal file
|
@ -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<Boolean, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
64
Mage.Common/src/mage/remote/method/SwapSeats.java
Normal file
64
Mage.Common/src/mage/remote/method/SwapSeats.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/WatchGame.java
Normal file
59
Mage.Common/src/mage/remote/method/WatchGame.java
Normal file
|
@ -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<Void, MageException> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
59
Mage.Common/src/mage/remote/method/WatchTable.java
Normal file
59
Mage.Common/src/mage/remote/method/WatchTable.java
Normal file
|
@ -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<Boolean, MageException> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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<TableEvent> () {
|
||||
@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<UUID, UUID> 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<UUID, UUID> 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<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
sessionManager.getSession(entry.getKey()).draftStarted(draft.getId(), entry.getValue());
|
||||
try {
|
||||
for (Entry<UUID, UUID> 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<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
if (entry.getValue().equals(playerId)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<TableEvent> () {
|
||||
@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<PlayerQueryEvent> () {
|
||||
@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<UUID, DraftSession> 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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<TableEvent> () {
|
||||
@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<UUID, GameSession> 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<? extends Ability> choices) {
|
||||
private synchronized void chooseAbility(UUID playerId, Collection<? extends Ability> 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<String> choices) {
|
||||
private synchronized void choose(UUID playerId, String message, Set<String> 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<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||
private synchronized void target(UUID playerId, String question, Cards cards, Set<UUID> targets, boolean required, Map<String, Serializable> 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<? extends Ability> abilities, boolean required, Map<String, Serializable> options) {
|
||||
private synchronized void target(UUID playerId, String question, Collection<? extends Ability> abilities, boolean required, Map<String, Serializable> 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<UUID, GameSession> 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() {
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.server.game;
|
|||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.MageException;
|
||||
import mage.server.SessionManager;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PlayerQueryEvent> () {
|
||||
@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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
134
Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java
Normal file
134
Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java
Normal file
|
@ -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<OracleOfMulDaya> {
|
||||
|
||||
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<OracleOfMulDayaEffect1> {
|
||||
|
||||
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<OracleOfMulDayaEffect2> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.interfaces;
|
||||
package mage;
|
||||
|
||||
/**
|
||||
* Root application exception.
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue