mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
rolled back changes since 0.7.3 R2 - going to switch client/server architecture
This commit is contained in:
parent
1f72804968
commit
c38804af5f
103 changed files with 997 additions and 4921 deletions
|
@ -46,8 +46,6 @@ import mage.client.constants.Constants.DeckEditorMode;
|
|||
import mage.client.deckeditor.collection.viewer.CollectionViewerPane;
|
||||
import mage.client.dialog.*;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.remote.Session;
|
||||
import mage.client.util.EDTExceptionHandler;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.components.ImagePanel;
|
||||
|
@ -73,37 +71,29 @@ import java.util.List;
|
|||
import java.util.prefs.Preferences;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.components.MageUI;
|
||||
import mage.client.deckeditor.DeckEditorPane;
|
||||
import mage.client.draft.DraftPane;
|
||||
import mage.client.draft.DraftPanel;
|
||||
import mage.client.game.GamePane;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.client.remote.CallbackClientImpl;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.table.TablesPane;
|
||||
import mage.client.tournament.TournamentPane;
|
||||
import mage.client.tournament.TournamentPanel;
|
||||
import mage.constants.Constants.SessionState;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.interfaces.Client;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.utils.MageVersion;
|
||||
import mage.sets.Sets;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.Connection.ProxyType;
|
||||
import mage.utils.Connection;
|
||||
import mage.utils.Connection.ProxyType;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class MageFrame extends javax.swing.JFrame implements Client {
|
||||
public class MageFrame extends javax.swing.JFrame {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MageFrame.class);
|
||||
|
||||
private static Session session;
|
||||
private static CallbackClient callbackClient;
|
||||
private ConnectDialog connectDialog;
|
||||
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
||||
private JLabel title;
|
||||
|
@ -112,10 +102,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
private UUID clientId;
|
||||
private static MagePane activeFrame;
|
||||
|
||||
private static Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
|
||||
private static Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
|
||||
private static Map<UUID, DraftPanel> drafts = new HashMap<UUID, DraftPanel>();
|
||||
private static Map<UUID, TournamentPanel> tournaments = new HashMap<UUID, TournamentPanel>();
|
||||
private static MageUI ui = new MageUI();
|
||||
|
||||
/**
|
||||
|
@ -133,7 +119,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
return prefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageVersion getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
@ -171,7 +156,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
|
||||
session = new Session(this);
|
||||
callbackClient = new CallbackClientImpl(this);
|
||||
connectDialog = new ConnectDialog();
|
||||
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
||||
ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
|
||||
|
@ -753,9 +737,9 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
}//GEN-LAST:event_btnExitActionPerformed
|
||||
|
||||
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||
if (session.getState() == SessionState.CONNECTED) {
|
||||
if (session.isConnected()) {
|
||||
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
session.disconnect(false);
|
||||
session.disconnect();
|
||||
showMessage("You have disconnected");
|
||||
}
|
||||
} else {
|
||||
|
@ -770,7 +754,7 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
}//GEN-LAST:event_btnAboutActionPerformed
|
||||
|
||||
public void exitApp() {
|
||||
session.disconnect(false);
|
||||
session.disconnect();
|
||||
Plugins.getInstance().shutdown();
|
||||
dispose();
|
||||
System.exit(0);
|
||||
|
@ -889,40 +873,10 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
return ui;
|
||||
}
|
||||
|
||||
public static ChatPanel getChat(UUID chatId) {
|
||||
return chats.get(chatId);
|
||||
}
|
||||
|
||||
public static void addChat(UUID chatId, ChatPanel chatPanel) {
|
||||
chats.put(chatId, chatPanel);
|
||||
}
|
||||
|
||||
public static GamePanel getGame(UUID gameId) {
|
||||
return games.get(gameId);
|
||||
}
|
||||
|
||||
public static void addGame(UUID gameId, GamePanel gamePanel) {
|
||||
games.put(gameId, gamePanel);
|
||||
}
|
||||
|
||||
public static DraftPanel getDraft(UUID draftId) {
|
||||
return drafts.get(draftId);
|
||||
}
|
||||
|
||||
public static void addDraft(UUID draftId, DraftPanel draftPanel) {
|
||||
drafts.put(draftId, draftPanel);
|
||||
}
|
||||
|
||||
public static void addTournament(UUID tournamentId, TournamentPanel tournament) {
|
||||
tournaments.put(tournamentId, tournament);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connected(final String message) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
setStatusText(message);
|
||||
|
@ -939,7 +893,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected() {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
setStatusText("Not connected");
|
||||
|
@ -960,7 +913,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(final String message) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
JOptionPane.showMessageDialog(desktopPane, message);
|
||||
|
@ -975,7 +927,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(final String message) {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
JOptionPane.showMessageDialog(desktopPane, message, "Error", JOptionPane.ERROR_MESSAGE);
|
||||
|
@ -990,11 +941,6 @@ public class MageFrame extends javax.swing.JFrame implements Client {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCallback(ClientCallback callback) {
|
||||
callbackClient.processCallback(callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||
|
|
|
@ -80,7 +80,7 @@ import mage.cards.MagePermanent;
|
|||
import mage.cards.TextPopup;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.game.PlayAreaPanel;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.DefaultActionCallback;
|
||||
import mage.client.util.ImageHelper;
|
||||
|
@ -382,13 +382,13 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
List<UUID> targets = card.getTargets();
|
||||
if (targets != null) {
|
||||
for (UUID uuid : targets) {
|
||||
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(uuid);
|
||||
PlayAreaPanel p = MageFrame.getSession().getGame(gameId).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
Point me = this.getLocationOnScreen();
|
||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red);
|
||||
} else {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
||||
for (PlayAreaPanel pa : MageFrame.getSession().getGame(gameId).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.*;
|
|||
import java.util.List;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.components.ColorPane;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
@ -130,9 +130,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
|||
public void connect(UUID chatId) {
|
||||
session = MageFrame.getSession();
|
||||
this.chatId = chatId;
|
||||
if (session.joinChat(chatId)) {
|
||||
MageFrame.addChat(chatId, this);
|
||||
}
|
||||
session.joinChat(chatId, this);
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
|
|
|
@ -50,8 +50,8 @@ import javax.swing.SwingWorker;
|
|||
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.util.Config;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.Connection.ProxyType;
|
||||
import mage.utils.Connection;
|
||||
import mage.utils.Connection.ProxyType;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ package mage.client.dialog;
|
|||
import mage.client.*;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JOptionPane;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.sets.Sets;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import javax.swing.SpinnerNumberModel;
|
|||
import mage.Constants.MultiplayerAttackOption;
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.table.TablePlayerPanel;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
|
|
|
@ -72,12 +72,12 @@
|
|||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="pnlPacks" pref="59" max="32767" attributes="0"/>
|
||||
<Component id="pnlPacks" pref="61" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="spnNumPlayers" alignment="0" pref="22" max="32767" attributes="1"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spnNumPlayers" alignment="0" pref="24" max="32767" attributes="1"/>
|
||||
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
|
||||
|
|
|
@ -45,7 +45,7 @@ import mage.Constants.MultiplayerAttackOption;
|
|||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.client.MageFrame;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.table.TournamentPlayerPanel;
|
||||
import mage.game.draft.DraftOptions;
|
||||
import mage.game.draft.DraftOptions.TimingOption;
|
||||
|
@ -260,12 +260,12 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel5)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
|
||||
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
|
||||
.addGap(11, 11, 11)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 22, Short.MAX_VALUE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
|
||||
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jLabel2))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" max="-2" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jLabel1" alignment="0" min="-2" pref="309" max="-2" attributes="0"/>
|
||||
<Component id="btnCancel" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" pref="14" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnCancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ReconnectDialog.java
|
||||
*
|
||||
* Created on 20-May-2011, 2:39:21 PM
|
||||
*/
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.SwingWorker;
|
||||
import mage.remote.Session;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ReconnectDialog extends MageDialog {
|
||||
|
||||
private static final int MAX_ATTEMPTS = 3;
|
||||
private boolean result = false;
|
||||
private boolean cancel = false;
|
||||
private ReconnectTask reconnectTask;
|
||||
|
||||
/** Creates new form ReconnectDialog */
|
||||
public ReconnectDialog() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void showDialog(Session session) {
|
||||
result = false;
|
||||
cancel = false;
|
||||
reconnectTask = new ReconnectTask(session, this);
|
||||
reconnectTask.execute();
|
||||
this.setModal(true);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void closeDialog() {
|
||||
if (reconnectTask != null) reconnectTask.cancel(true);
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
public void update(String message) {
|
||||
this.jLabel1.setText(message);
|
||||
}
|
||||
|
||||
public boolean getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
btnCancel = new javax.swing.JButton();
|
||||
|
||||
btnCancel.setText("Cancel");
|
||||
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(btnCancel, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.cancel = true;
|
||||
closeDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
class ReconnectTask extends SwingWorker<Void, String> {
|
||||
|
||||
private Session session;
|
||||
private ReconnectDialog dialog;
|
||||
|
||||
ReconnectTask(Session session, ReconnectDialog dialog) {
|
||||
this.session = session;
|
||||
this.dialog = dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
int numAttempts = 0;
|
||||
while (numAttempts < MAX_ATTEMPTS && !cancel) {
|
||||
numAttempts++;
|
||||
this.publish("Attempting to reconnect: attempt " + numAttempts + "of " + MAX_ATTEMPTS);
|
||||
Thread.sleep(2000);
|
||||
if (session.connect()) {
|
||||
result = true;
|
||||
closeDialog();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(List<String> view) {
|
||||
dialog.update(view.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jSplitPane1" pref="271" max="32767" attributes="0"/>
|
||||
<Component id="jSplitPane1" pref="275" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnMoveDown" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import javax.swing.SwingWorker;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.view.SeatView;
|
||||
import mage.view.TableView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
|
@ -41,7 +41,7 @@ import java.util.UUID;
|
|||
import javax.swing.Timer;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.view.DraftPickView;
|
||||
|
@ -81,7 +81,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
public synchronized void showDraft(UUID draftId) {
|
||||
this.draftId = draftId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addDraft(draftId, this);
|
||||
session.addDraft(draftId, this);
|
||||
if (!session.joinDraft(draftId))
|
||||
hideDraft();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import javax.swing.JPopupMenu;
|
|||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import mage.client.MageFrame;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.view.AbilityPickerView;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import javax.swing.*;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.components.MageTextArea;
|
||||
import mage.client.components.arcane.GlowText;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ import mage.client.dialog.PickNumberDialog;
|
|||
import mage.client.dialog.ShowCardsDialog;
|
||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.PhaseManager;
|
||||
|
@ -161,7 +161,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addGame(gameId, this);
|
||||
session.addGame(gameId, this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
this.abilityPicker.init(session, gameId);
|
||||
|
@ -178,7 +178,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.playerId = null;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addGame(gameId, this);
|
||||
session.addGame(gameId, this);
|
||||
this.feedbackPanel.init(gameId);
|
||||
this.feedbackPanel.clear();
|
||||
this.btnConcede.setVisible(false);
|
||||
|
@ -194,7 +194,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
this.playerId = null;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addGame(gameId, this);
|
||||
session.addGame(gameId, this);
|
||||
this.feedbackPanel.clear();
|
||||
this.btnConcede.setVisible(false);
|
||||
this.btnStopWatching.setVisible(false);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
|
|
|
@ -39,7 +39,7 @@ import java.util.UUID;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.dialog.ShowCardsDialog;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Config;
|
||||
import mage.view.PlayerView;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import mage.client.components.HoverButton;
|
|||
import mage.client.components.MageRoundPane;
|
||||
import mage.client.components.arcane.ManaSymbols;
|
||||
import mage.client.dialog.ShowCardsDialog;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Command;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
|
|
|
@ -18,7 +18,7 @@ import mage.client.cards.BigCard;
|
|||
import mage.client.components.MageComponents;
|
||||
import mage.client.game.PlayAreaPanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.DefaultActionCallback;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
|
@ -82,13 +82,13 @@ public class MageActionCallback implements ActionCallback {
|
|||
for (UUID uuid : targets) {
|
||||
//System.out.println("Getting play area panel for uuid: " + uuid);
|
||||
|
||||
PlayAreaPanel p = MageFrame.getGame(data.gameId).getPlayers().get(uuid);
|
||||
PlayAreaPanel p = session.getGame(data.gameId).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.addArrow((int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red);
|
||||
} else {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
for (PlayAreaPanel pa : session.getGame(data.gameId).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
|
@ -105,7 +105,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
Point me = new Point(data.locationOnScreen);
|
||||
me.translate(-parentPoint.x, -parentPoint.y);
|
||||
UUID uuid = data.card.getParentId();
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
for (PlayAreaPanel pa : session.getGame(data.gameId).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point source = permanent.getLocationOnScreen();
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
package mage.client.remote;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.client.MageFrame;
|
||||
|
@ -38,10 +40,8 @@ import mage.client.draft.DraftPanel;
|
|||
import mage.client.game.GamePanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.object.SaveObjectUtil;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.DraftClientMessage;
|
||||
|
@ -55,26 +55,26 @@ import org.apache.log4j.Logger;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CallbackClientImpl implements CallbackClient {
|
||||
public class Client implements CallbackClient {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
private final static Logger logger = Logger.getLogger(Client.class);
|
||||
|
||||
private UUID clientId;
|
||||
private MageFrame frame;
|
||||
private Session session;
|
||||
private int messageId = 0;
|
||||
|
||||
public CallbackClientImpl(MageFrame frame) {
|
||||
public Client(Session session, MageFrame frame) {
|
||||
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.frame = frame;
|
||||
this.session = session;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void processCallback(final ClientCallback callback) {
|
||||
logger.info(callback.getMessageId() + " - " + callback.getMethod());
|
||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -101,7 +101,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
else if (callback.getMethod().equals("chatMessage")) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
ChatPanel panel = frame.getChat(callback.getObjectId());
|
||||
ChatPanel panel = session.getChat(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
if (message.isUserMessage() && panel.getConnectedChat() != null) {
|
||||
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
|
||||
|
@ -111,31 +111,31 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("replayInit")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.init((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayDone")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.modalMessage((String) callback.getData());
|
||||
panel.hideGame();
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("replayUpdate")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInit")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.init((GameView) callback.getData());
|
||||
|
||||
session.ack("gameInit");
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameOver")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.modalMessage((String) callback.getData());
|
||||
panel.hideGame();
|
||||
|
@ -143,53 +143,53 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
else if (callback.getMethod().equals("gameAsk")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.ask(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameTarget")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelect")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.select(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChooseAbility")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChoose")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.getChoice(message.getMessage(), message.getStrings());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.playMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayXMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.playXMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelectAmount")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameUpdate")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
if (callback.getMessageId() > messageId) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
GamePanel panel = session.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.inform(message.getMessage(), message.getGameView());
|
||||
}
|
||||
|
@ -214,18 +214,18 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
construct(message.getDeck(), message.getTableId(), message.getTime());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftOver")) {
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
DraftPanel panel = session.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.hideDraft();
|
||||
}
|
||||
else if (callback.getMethod().equals("draftPick")) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
DraftPanel panel = session.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftUpdate")) {
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
DraftPanel panel = session.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateDraft((DraftView) callback.getData());
|
||||
}
|
||||
|
@ -238,10 +238,10 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("draftInit")) {
|
||||
|
||||
session.ack("draftInit");
|
||||
}
|
||||
else if (callback.getMethod().equals("tournamentInit")) {
|
||||
|
||||
session.ack("tournamentInit");
|
||||
}
|
||||
messageId = callback.getMessageId();
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
});
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
public UUID getId() throws RemoteException {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,9 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
|
||||
private void handleException(Exception ex) {
|
||||
logger.fatal("Client error\n", ex);
|
||||
frame.showError("Error: " + ex.getMessage());
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unrecoverable client error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.disconnect();
|
||||
frame.disableButtons();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.remote;
|
||||
package mage.client.remote;
|
||||
|
||||
/**
|
||||
*
|
821
Mage.Client/src/main/java/mage/client/remote/Session.java
Normal file
821
Mage.Client/src/main/java/mage/client/remote/Session.java
Normal file
|
@ -0,0 +1,821 @@
|
|||
/*
|
||||
* Copyright 2010 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.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;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
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.draft.DraftPanel;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.client.tournament.TournamentPanel;
|
||||
import mage.client.util.Config;
|
||||
import mage.game.GameException;
|
||||
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.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Session {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Session.class);
|
||||
private static ScheduledExecutorService sessionExecutor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
private UUID sessionId;
|
||||
private Server server;
|
||||
private Client client;
|
||||
private String userName;
|
||||
private MageFrame frame;
|
||||
private ServerState serverState;
|
||||
private Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
|
||||
private Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
|
||||
private Map<UUID, DraftPanel> drafts = new HashMap<UUID, DraftPanel>();
|
||||
private Map<UUID, TournamentPanel> tournaments = new HashMap<UUID, TournamentPanel>();
|
||||
private CallbackClientDaemon callbackDaemon;
|
||||
private ScheduledFuture<?> future;
|
||||
private MageUI ui = new MageUI();
|
||||
|
||||
public Session(MageFrame frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
|
||||
public boolean connect(Connection connection) {
|
||||
if (isConnected()) {
|
||||
disconnect();
|
||||
}
|
||||
try {
|
||||
System.setSecurityManager(null);
|
||||
System.setProperty("http.nonProxyHosts", "code.google.com");
|
||||
System.setProperty("socksNonProxyHosts", "code.google.com");
|
||||
|
||||
// clear previous values
|
||||
System.clearProperty("socksProxyHost");
|
||||
System.clearProperty("socksProxyPort");
|
||||
System.clearProperty("http.proxyHost");
|
||||
System.clearProperty("http.proxyPort");
|
||||
|
||||
switch (connection.getProxyType()) {
|
||||
case SOCKS:
|
||||
System.setProperty("socksProxyHost", connection.getProxyHost());
|
||||
System.setProperty("socksProxyPort", Integer.toString(connection.getProxyPort()));
|
||||
break;
|
||||
case HTTP:
|
||||
System.setProperty("http.proxyHost", connection.getProxyHost());
|
||||
System.setProperty("http.proxyPort", Integer.toString(connection.getProxyPort()));
|
||||
Authenticator.setDefault(new MageAuthenticator(connection.getProxyUsername(), connection.getProxyPassword()));
|
||||
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();
|
||||
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() + " ");
|
||||
frame.enableButtons();
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
logger.fatal("", ex);
|
||||
disconnect();
|
||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
||||
} catch (RemoteException ex) {
|
||||
logger.fatal("Unable to connect to server - ", ex);
|
||||
disconnect();
|
||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
||||
} catch (NotBoundException ex) {
|
||||
logger.fatal("Unable to connect to server - ", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
|
||||
if (isConnected()) {
|
||||
try {
|
||||
for (UUID chatId: chats.keySet()) {
|
||||
server.leaveChat(chatId, sessionId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
//swallow all exceptions at this point
|
||||
}
|
||||
try {
|
||||
//TODO: stop daemon
|
||||
if (server != null)
|
||||
server.deregisterClient(sessionId);
|
||||
} catch (RemoteException ex) {
|
||||
logger.fatal("Error disconnecting ...", ex);
|
||||
} catch (MageException ex) {
|
||||
logger.fatal("Error disconnecting ...", ex);
|
||||
}
|
||||
removeServer();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeServer() {
|
||||
if (future != null && !future.isDone())
|
||||
future.cancel(true);
|
||||
server = null;
|
||||
frame.hideGames();
|
||||
frame.hideTables();
|
||||
frame.setStatusText("Not connected");
|
||||
frame.disableButtons();
|
||||
logger.info("Disconnected ... ");
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "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 boolean ping() {
|
||||
try {
|
||||
return server.ping(sessionId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return server != null;
|
||||
}
|
||||
|
||||
public String[] getPlayerTypes() {
|
||||
return serverState.getPlayerTypes();
|
||||
}
|
||||
|
||||
public List<GameTypeView> getGameTypes() {
|
||||
return serverState.getGameTypes();
|
||||
}
|
||||
|
||||
public String[] getDeckTypes() {
|
||||
return serverState.getDeckTypes();
|
||||
}
|
||||
|
||||
public List<TournamentTypeView> getTournamentTypes() {
|
||||
return serverState.getTournamentTypes();
|
||||
}
|
||||
|
||||
public boolean isTestMode() {
|
||||
if (serverState != null)
|
||||
return serverState.isTestMode();
|
||||
return false;
|
||||
}
|
||||
|
||||
public ChatPanel getChat(UUID chatId) {
|
||||
return chats.get(chatId);
|
||||
}
|
||||
|
||||
public GamePanel getGame(UUID gameId) {
|
||||
return games.get(gameId);
|
||||
}
|
||||
|
||||
public void addGame(UUID gameId, GamePanel gamePanel) {
|
||||
games.put(gameId, gamePanel);
|
||||
}
|
||||
|
||||
public DraftPanel getDraft(UUID draftId) {
|
||||
return drafts.get(draftId);
|
||||
}
|
||||
|
||||
public void addDraft(UUID draftId, DraftPanel draftPanel) {
|
||||
drafts.put(draftId, draftPanel);
|
||||
}
|
||||
|
||||
public void addTournament(UUID tournamentId, TournamentPanel tournament) {
|
||||
tournaments.put(tournamentId, tournament);
|
||||
}
|
||||
|
||||
public UUID getMainRoomId() {
|
||||
try {
|
||||
return server.getMainRoomId();
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getRoomChatId(UUID roomId) {
|
||||
try {
|
||||
return server.getRoomChatId(roomId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getTableChatId(UUID tableId) {
|
||||
try {
|
||||
return server.getTableChatId(tableId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getGameChatId(UUID gameId) {
|
||||
try {
|
||||
return server.getGameChatId(gameId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TableView getTable(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
return server.getTable(roomId, tableId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean watchTable(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
server.watchTable(sessionId, roomId, tableId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) {
|
||||
try {
|
||||
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (GameException ex) {
|
||||
handleGameException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill) {
|
||||
try {
|
||||
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (GameException ex) {
|
||||
handleGameException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
|
||||
try {
|
||||
return server.getTables(roomId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
throw new MageRemoteException();
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
throw new MageRemoteException();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<String> getConnectedPlayers(UUID roomId) throws MageRemoteException {
|
||||
try {
|
||||
return server.getConnectedPlayers(roomId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
throw new MageRemoteException();
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
throw new MageRemoteException();
|
||||
}
|
||||
}
|
||||
|
||||
public TournamentView getTournament(UUID tournamentId) throws MageRemoteException {
|
||||
try {
|
||||
return server.getTournament(tournamentId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
throw new MageRemoteException();
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
throw new MageRemoteException();
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getTournamentChatId(UUID tournamentId) {
|
||||
try {
|
||||
return server.getTournamentChatId(tournamentId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean sendPlayerUUID(UUID gameId, UUID data) {
|
||||
try {
|
||||
server.sendPlayerUUID(gameId, sessionId, data);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendPlayerBoolean(UUID gameId, boolean data) {
|
||||
try {
|
||||
server.sendPlayerBoolean(gameId, sessionId, data);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendPlayerInteger(UUID gameId, int data) {
|
||||
try {
|
||||
server.sendPlayerInteger(gameId, sessionId, data);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendPlayerString(UUID gameId, String data) {
|
||||
try {
|
||||
server.sendPlayerString(gameId, sessionId, data);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DraftPickView sendCardPick(UUID draftId, UUID cardId) {
|
||||
try {
|
||||
return server.sendCardPick(draftId, sessionId, cardId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean joinChat(UUID chatId, ChatPanel chat) {
|
||||
try {
|
||||
server.joinChat(chatId, sessionId, userName);
|
||||
chats.put(chatId, chat);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean leaveChat(UUID chatId) {
|
||||
try {
|
||||
server.leaveChat(chatId, sessionId);
|
||||
chats.remove(chatId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendChatMessage(UUID chatId, String message) {
|
||||
try {
|
||||
server.sendChatMessage(chatId, userName, message);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinGame(UUID gameId) {
|
||||
try {
|
||||
server.joinGame(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinDraft(UUID draftId) {
|
||||
try {
|
||||
server.joinDraft(draftId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinTournament(UUID tournamentId) {
|
||||
try {
|
||||
server.joinTournament(tournamentId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean watchGame(UUID gameId) {
|
||||
try {
|
||||
server.watchGame(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean replayGame(UUID gameId) {
|
||||
try {
|
||||
server.replayGame(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TableView createTable(UUID roomId, MatchOptions matchOptions) {
|
||||
try {
|
||||
return server.createTable(sessionId, roomId, matchOptions);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) {
|
||||
try {
|
||||
return server.createTournamentTable(sessionId, roomId, tournamentOptions);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isTableOwner(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
return server.isTableOwner(sessionId, roomId, tableId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeTable(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
server.removeTable(sessionId, roomId, tableId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) {
|
||||
try {
|
||||
server.swapSeats(sessionId, roomId, tableId, seatNum1, seatNum2);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean leaveTable(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
server.leaveTable(sessionId, roomId, tableId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean startGame(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
server.startMatch(sessionId, roomId, tableId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean startTournament(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
server.startTournament(sessionId, roomId, tableId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId) {
|
||||
try {
|
||||
server.startChallenge(sessionId, roomId, tableId, challengeId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||
try {
|
||||
return server.submitDeck(sessionId, tableId, deck);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (GameException ex) {
|
||||
handleGameException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean concedeGame(UUID gameId) {
|
||||
try {
|
||||
server.concedeGame(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean stopWatching(UUID gameId) {
|
||||
try {
|
||||
server.stopWatching(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean startReplay(UUID gameId) {
|
||||
try {
|
||||
server.startReplay(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean stopReplay(UUID gameId) {
|
||||
try {
|
||||
server.stopReplay(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextPlay(UUID gameId) {
|
||||
try {
|
||||
server.nextPlay(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean previousPlay(UUID gameId) {
|
||||
try {
|
||||
server.previousPlay(gameId, sessionId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
|
||||
try {
|
||||
server.cheat(gameId, sessionId, playerId, deckList);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleRemoteException(RemoteException ex) {
|
||||
logger.fatal("Communication error", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Critical server error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private void handleMageException(MageException ex) {
|
||||
logger.fatal("Server error", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Critical server error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
disconnect();
|
||||
}
|
||||
|
||||
private void handleGameException(GameException ex) {
|
||||
logger.warn(ex.getMessage());
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public MageUI getUI() {
|
||||
return ui;
|
||||
}
|
||||
|
||||
public Server getServerRef() {
|
||||
return server;
|
||||
}
|
||||
|
||||
class ServerPinger implements Runnable {
|
||||
|
||||
private int missed = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!ping()) {
|
||||
missed++;
|
||||
if (missed > 10) {
|
||||
logger.info("Connection to server timed out");
|
||||
removeServer();
|
||||
}
|
||||
}
|
||||
else {
|
||||
missed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class MageAuthenticator extends Authenticator {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public MageAuthenticator(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordAuthentication getPasswordAuthentication () {
|
||||
return new PasswordAuthentication (username, password.toCharArray());
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ import java.util.UUID;
|
|||
import javax.swing.DefaultComboBoxModel;
|
||||
|
||||
import mage.client.MageFrame;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
|
|
|
@ -43,8 +43,8 @@ import mage.client.dialog.JoinTableDialog;
|
|||
import mage.client.dialog.NewTableDialog;
|
||||
import mage.client.dialog.NewTournamentDialog;
|
||||
import mage.client.dialog.TableWaitingDialog;
|
||||
import mage.remote.MageRemoteException;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.MageRemoteException;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.ButtonColumn;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.sets.Sets;
|
||||
|
|
|
@ -38,7 +38,7 @@ import java.util.UUID;
|
|||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import mage.client.MageFrame;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -48,8 +48,8 @@ import java.util.concurrent.ExecutionException;
|
|||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import mage.client.MageFrame;
|
||||
import mage.remote.MageRemoteException;
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.MageRemoteException;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.ButtonColumn;
|
||||
import mage.view.RoundView;
|
||||
import mage.view.TournamentGameView;
|
||||
|
@ -104,7 +104,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
public synchronized void showTournament(UUID tournamentId) {
|
||||
this.tournamentId = tournamentId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addTournament(tournamentId, this);
|
||||
session.addTournament(tournamentId, this);
|
||||
UUID chatRoomId = session.getTournamentChatId(tournamentId);
|
||||
if (session.joinTournament(tournamentId) && chatRoomId != null) {
|
||||
this.chatPanel1.connect(chatRoomId);
|
||||
|
|
|
@ -3,7 +3,7 @@ package mage.client.util;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.remote.Session;
|
||||
import mage.client.remote.Session;
|
||||
import mage.view.CardView;
|
||||
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.utils.MageVersion;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public interface Client extends CallbackClient {
|
||||
|
||||
public UUID getId();
|
||||
public MageVersion getVersion();
|
||||
public void connected(String message);
|
||||
public void disconnected();
|
||||
public void showMessage(String message);
|
||||
public void showError(String message);
|
||||
|
||||
}
|
|
@ -28,12 +28,12 @@
|
|||
|
||||
package mage.interfaces;
|
||||
|
||||
import mage.MageException;
|
||||
import mage.game.match.MatchOptions;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.game.GameException;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
|
@ -54,6 +54,7 @@ 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;
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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,9 +31,6 @@ package mage.interfaces.callback;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import mage.MageException;
|
||||
import mage.remote.ServerUnavailable;
|
||||
import mage.remote.Session;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
@ -44,15 +41,14 @@ public class CallbackClientDaemon extends Thread {
|
|||
|
||||
private final static Logger logger = Logger.getLogger(CallbackClientDaemon.class);
|
||||
|
||||
private ExecutorService callbackExecutor = Executors.newFixedThreadPool(1);
|
||||
private static ExecutorService callbackExecutor = Executors.newCachedThreadPool();
|
||||
private final CallbackClient client;
|
||||
private final Session session;
|
||||
private final CallbackServer server;
|
||||
private final UUID id;
|
||||
private boolean end = false;
|
||||
|
||||
public CallbackClientDaemon(UUID id, CallbackClient client, Session session) {
|
||||
public CallbackClientDaemon(UUID id, CallbackClient client, CallbackServer server) {
|
||||
this.client = client;
|
||||
this.session = session;
|
||||
this.server = server;
|
||||
this.id = id;
|
||||
setDaemon(true);
|
||||
start();
|
||||
|
@ -60,30 +56,25 @@ public class CallbackClientDaemon extends Thread {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while(!end && session.isConnected()) {
|
||||
try {
|
||||
final ClientCallback callback = session.callback(id);
|
||||
session.ack(id, callback.getMessageId());
|
||||
if (callbackExecutor.isShutdown())
|
||||
logger.fatal("Attempt to submit callback to shutdown executor");
|
||||
else
|
||||
client.processCallback(callback);
|
||||
} catch (ServerUnavailable ex) {
|
||||
session.handleServerUnavailable(ex);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("CallbackClientDaemon failed ", ex);
|
||||
try {
|
||||
while(true) {
|
||||
final ClientCallback callback = server.callback(id);
|
||||
callbackExecutor.submit(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
client.processCallback(callback);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.fatal("CallbackClientDaemon error ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
);
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
logger.fatal("CallbackClientDaemon error ", ex);
|
||||
}
|
||||
logger.info("CallbackClientDaemon stopped");
|
||||
}
|
||||
|
||||
public void stopDaemon() {
|
||||
end = true;
|
||||
callbackExecutor.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public interface CallbackServer {
|
||||
|
||||
public ClientCallback callback(UUID clientId) throws RemoteException, CallbackException;
|
||||
public void ack(int messageId, UUID sessionId) throws RemoteException, CallbackException;
|
||||
public ClientCallback callback(UUID clientId) throws RemoteException;
|
||||
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ package mage.interfaces.callback;
|
|||
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import mage.utils.CompressUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +85,7 @@ public class CallbackServerSession {
|
|||
waiting.await();
|
||||
}
|
||||
callback.setMethod(call.getMethod());
|
||||
callback.setData(CompressUtil.compress(call.getData()));
|
||||
callback.setData(call.getData());
|
||||
callback.setObjectId(call.getObjectId());
|
||||
callback.setMessageId(call.getMessageId());
|
||||
callbackCalled.signal();
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* 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.MageException;
|
||||
import mage.interfaces.Server;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public abstract class AbstractRemoteMethodCall<T> {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(AbstractRemoteMethodCall.class);
|
||||
|
||||
public T makeCall() throws ServerUnavailable, MageException {
|
||||
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, MageException;
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class RMIClientDaemon extends Thread {
|
||||
|
||||
private final RemoteMethodCallQueue q;
|
||||
|
||||
public RMIClientDaemon(RemoteMethodCallQueue q) {
|
||||
this.q = q;
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
RemoteMethodCall call = q.take();
|
||||
call.makeCall();
|
||||
synchronized (call) {
|
||||
call.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* 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.MageException;
|
||||
import mage.constants.Constants.SessionState;
|
||||
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> extends AbstractRemoteMethodCall<T> {
|
||||
|
||||
protected final static Logger logger = Logger.getLogger(RemoteMethodCall.class);
|
||||
|
||||
protected Connection connection;
|
||||
protected String name;
|
||||
protected T returnVal;
|
||||
protected boolean exception = false;
|
||||
protected MageException ex;
|
||||
protected SessionState allowedState;
|
||||
|
||||
public RemoteMethodCall(Connection connection, String name, SessionState allowedState){
|
||||
this.connection = connection;
|
||||
this.name = name;
|
||||
this.allowedState = allowedState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T makeCall() {
|
||||
returnVal = null;
|
||||
logger.debug("Calling: " + name);
|
||||
try {
|
||||
returnVal = super.makeCall();
|
||||
}
|
||||
catch (ServerUnavailable e) {
|
||||
this.exception = true;
|
||||
}
|
||||
catch (MageException e) {
|
||||
this.exception = true;
|
||||
this.ex = e;
|
||||
}
|
||||
finally {
|
||||
ServerCache.noLongerUsingServer(connection);
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public T makeDirectCall() throws ServerUnavailable, MageException {
|
||||
T returnValue = null;
|
||||
logger.debug("Calling direct: " + name);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
protected void remoteExceptionOccured(RemoteException remoteException) {
|
||||
ServerCache.removeServerFromCache(connection);
|
||||
}
|
||||
|
||||
public T getReturnVal() {
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public MageException getException() {
|
||||
return ex;
|
||||
}
|
||||
|
||||
public boolean isException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public SessionState getAllowedState() {
|
||||
return allowedState;
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* 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.concurrent.LinkedBlockingQueue;
|
||||
import mage.MageException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class RemoteMethodCallQueue extends LinkedBlockingQueue<RemoteMethodCall> {
|
||||
|
||||
public void callMethod(RemoteMethodCall call) throws ServerUnavailable, MageException {
|
||||
synchronized (call) {
|
||||
try {
|
||||
this.offer(call);
|
||||
call.wait();
|
||||
if (call.isException()) {
|
||||
if (call.getException() != null)
|
||||
throw call.getException();
|
||||
else
|
||||
throw new ServerUnavailable();
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCalls() {
|
||||
RemoteMethodCall call = null;
|
||||
while (true) {
|
||||
call = poll();
|
||||
if (call == null)
|
||||
return;
|
||||
synchronized (call) {
|
||||
call.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* 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 {
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* 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 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 RetryStrategy {
|
||||
public static final int DEFAULT_NUMBER_OF_RETRIES = 3;
|
||||
private int _numberOfTriesLeft;
|
||||
private final static Logger logger = Logger.getLogger(RetryStrategy.class);
|
||||
|
||||
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();
|
||||
logger.warn("Error calling server, waiting " + timeToWait + "ms before retrying");
|
||||
try {
|
||||
Thread.sleep(timeToWait );
|
||||
}
|
||||
catch (InterruptedException ignored) {}
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* 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{
|
||||
}
|
||||
}
|
|
@ -1,548 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 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.net.Authenticator;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.remote.method.*;
|
||||
import mage.game.GameException;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.InvalidDeckException;
|
||||
import mage.constants.Constants.SessionState;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.interfaces.Client;
|
||||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.CallbackClientDaemon;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.MageVersion;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
import mage.view.TournamentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Session {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Session.class);
|
||||
private static ScheduledExecutorService sessionExecutor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
private UUID sessionId;
|
||||
private Client client;
|
||||
private String userName;
|
||||
private ServerState serverState;
|
||||
private SessionState sessionState = SessionState.DISCONNECTED;
|
||||
private CallbackClientDaemon callbackDaemon;
|
||||
private RMIClientDaemon rmiDaemon;
|
||||
private RemoteMethodCallQueue q = new RemoteMethodCallQueue();
|
||||
private ScheduledFuture<?> future;
|
||||
private Connection connection;
|
||||
|
||||
public Session(Client client) {
|
||||
this.client = client;
|
||||
rmiDaemon = new RMIClientDaemon(q);
|
||||
}
|
||||
|
||||
public synchronized boolean connect(Connection connection) {
|
||||
cleanupSession();
|
||||
this.connection = connection;
|
||||
return connect();
|
||||
}
|
||||
|
||||
public boolean connect() {
|
||||
sessionState = SessionState.CONNECTING;
|
||||
try {
|
||||
System.setSecurityManager(null);
|
||||
System.setProperty("http.nonProxyHosts", "code.google.com");
|
||||
System.setProperty("socksNonProxyHosts", "code.google.com");
|
||||
|
||||
// clear previous values
|
||||
System.clearProperty("socksProxyHost");
|
||||
System.clearProperty("socksProxyPort");
|
||||
System.clearProperty("http.proxyHost");
|
||||
System.clearProperty("http.proxyPort");
|
||||
|
||||
switch (connection.getProxyType()) {
|
||||
case SOCKS:
|
||||
System.setProperty("socksProxyHost", connection.getProxyHost());
|
||||
System.setProperty("socksProxyPort", Integer.toString(connection.getProxyPort()));
|
||||
break;
|
||||
case HTTP:
|
||||
System.setProperty("http.proxyHost", connection.getProxyHost());
|
||||
System.setProperty("http.proxyPort", Integer.toString(connection.getProxyPort()));
|
||||
Authenticator.setDefault(new MageAuthenticator(connection.getProxyUsername(), connection.getProxyPassword()));
|
||||
break;
|
||||
}
|
||||
Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort());
|
||||
this.userName = connection.getUsername();
|
||||
sessionId = registerClient(userName, client.getId(), client.getVersion());
|
||||
serverState = getServerState();
|
||||
sessionState = SessionState.CONNECTED;
|
||||
callbackDaemon = new CallbackClientDaemon(sessionId, client, this);
|
||||
future = sessionExecutor.scheduleWithFixedDelay(new ServerPinger(), 5, 5, TimeUnit.SECONDS);
|
||||
logger.info("Connected to RMI server at " + connection.getHost() + ":" + connection.getPort());
|
||||
client.connected("Connected to " + connection.getHost() + ":" + connection.getPort() + " ");
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("", ex);
|
||||
sessionState = SessionState.SERVER_UNAVAILABLE;
|
||||
disconnect(false);
|
||||
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void disconnect(boolean showMessage) {
|
||||
if (sessionState == SessionState.CONNECTED)
|
||||
sessionState = SessionState.DISCONNECTING;
|
||||
cleanupSession();
|
||||
if (connection == null)
|
||||
return;
|
||||
if (sessionState == SessionState.CONNECTED) {
|
||||
try {
|
||||
deregisterClient();
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error disconnecting ...", ex);
|
||||
}
|
||||
}
|
||||
ServerCache.removeServerFromCache(connection);
|
||||
client.disconnected();
|
||||
logger.info("Disconnected ... ");
|
||||
if (sessionState == SessionState.SERVER_UNAVAILABLE && showMessage) {
|
||||
client.showError("Server error. You have been disconnected");
|
||||
}
|
||||
else {
|
||||
sessionState = SessionState.DISCONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupSession() {
|
||||
q.clearCalls();
|
||||
if (future != null && !future.isDone())
|
||||
future.cancel(true);
|
||||
if (callbackDaemon != null)
|
||||
callbackDaemon.stopDaemon();
|
||||
}
|
||||
|
||||
private boolean handleCall(RemoteMethodCall method) {
|
||||
try {
|
||||
if (sessionState == method.getAllowedState()) {
|
||||
q.callMethod(method);
|
||||
return true;
|
||||
}
|
||||
} catch (ServerUnavailable ex) {
|
||||
handleServerUnavailable(ex);
|
||||
} catch (GameException ex) {
|
||||
handleGameException(ex);
|
||||
} catch (InvalidDeckException ex) {
|
||||
handleInvalidDeckException(ex);
|
||||
} catch (MageException ex) {
|
||||
logger.fatal(method.getName() + " error", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean ping() {
|
||||
Ping method = new Ping(connection, sessionId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return false;
|
||||
}
|
||||
|
||||
private UUID registerClient(String userName, UUID clientId, MageVersion version) throws MageException, ServerUnavailable {
|
||||
if (sessionState == SessionState.CONNECTING) {
|
||||
RegisterClient method = new RegisterClient(connection, userName, clientId, version);
|
||||
return method.makeDirectCall();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deregisterClient() throws MageException, ServerUnavailable {
|
||||
DeregisterClient method = new DeregisterClient(connection, sessionId);
|
||||
method.makeDirectCall();
|
||||
}
|
||||
|
||||
private ServerState getServerState() {
|
||||
GetServerState method = new GetServerState(connection);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public SessionState getState() {
|
||||
return sessionState;
|
||||
}
|
||||
public boolean isConnected() {
|
||||
return sessionState == SessionState.CONNECTED;
|
||||
}
|
||||
|
||||
public String[] getPlayerTypes() {
|
||||
return serverState.getPlayerTypes();
|
||||
}
|
||||
|
||||
public List<GameTypeView> getGameTypes() {
|
||||
return serverState.getGameTypes();
|
||||
}
|
||||
|
||||
public String[] getDeckTypes() {
|
||||
return serverState.getDeckTypes();
|
||||
}
|
||||
|
||||
public List<TournamentTypeView> getTournamentTypes() {
|
||||
return serverState.getTournamentTypes();
|
||||
}
|
||||
|
||||
public boolean isTestMode() {
|
||||
if (serverState != null)
|
||||
return serverState.isTestMode();
|
||||
return false;
|
||||
}
|
||||
|
||||
public ClientCallback callback(UUID clientId) throws ServerUnavailable, MageException {
|
||||
if (sessionState == SessionState.CONNECTED) {
|
||||
Callback method = new Callback(connection, clientId);
|
||||
return method.makeDirectCall();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean ack(UUID clientId, int messageId) {
|
||||
Ack method = new Ack(connection, clientId, messageId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public UUID getMainRoomId() {
|
||||
GetMainRoomId method = new GetMainRoomId(connection);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getRoomChatId(UUID roomId) {
|
||||
GetRoomChatId method = new GetRoomChatId(connection, roomId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getTableChatId(UUID tableId) {
|
||||
GetTableChatId method = new GetTableChatId(connection, tableId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getGameChatId(UUID gameId) {
|
||||
GetGameChatId method = new GetGameChatId(connection, gameId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public TableView getTable(UUID roomId, UUID tableId) {
|
||||
GetTable method = new GetTable(connection, roomId, tableId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean watchTable(UUID roomId, UUID tableId) {
|
||||
WatchTable method = new WatchTable(connection, sessionId, roomId, tableId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
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);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
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);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
|
||||
GetTables method = new GetTables(connection, roomId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<String> getConnectedPlayers(UUID roomId) throws MageRemoteException {
|
||||
GetConnectedPlayers method = new GetConnectedPlayers(connection, roomId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public TournamentView getTournament(UUID tournamentId) throws MageRemoteException {
|
||||
GetTournament method = new GetTournament(connection, tournamentId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public UUID getTournamentChatId(UUID tournamentId) {
|
||||
GetTournamentChatId method = new GetTournamentChatId(connection, tournamentId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean sendPlayerUUID(UUID gameId, UUID data) {
|
||||
SendPlayerUUID method = new SendPlayerUUID(connection, sessionId, gameId, data);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean sendPlayerBoolean(UUID gameId, boolean data) {
|
||||
SendPlayerBoolean method = new SendPlayerBoolean(connection, sessionId, gameId, data);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean sendPlayerInteger(UUID gameId, int data) {
|
||||
SendPlayerInteger method = new SendPlayerInteger(connection, sessionId, gameId, data);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean sendPlayerString(UUID gameId, String data) {
|
||||
SendPlayerString method = new SendPlayerString(connection, sessionId, gameId, data);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public DraftPickView sendCardPick(UUID draftId, UUID cardId) {
|
||||
SendCardPick method = new SendCardPick(connection, sessionId, draftId, cardId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean joinChat(UUID chatId) {
|
||||
JoinChat method = new JoinChat(connection, sessionId, chatId, userName);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean leaveChat(UUID chatId) {
|
||||
LeaveChat method = new LeaveChat(connection, sessionId, chatId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean sendChatMessage(UUID chatId, String message) {
|
||||
SendChatMessage method = new SendChatMessage(connection, chatId, message, userName);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean joinGame(UUID gameId) {
|
||||
JoinGame method = new JoinGame(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean joinDraft(UUID draftId) {
|
||||
JoinDraft method = new JoinDraft(connection, sessionId, draftId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean joinTournament(UUID tournamentId) {
|
||||
JoinTournament method = new JoinTournament(connection, sessionId, tournamentId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean watchGame(UUID gameId) {
|
||||
WatchGame method = new WatchGame(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean replayGame(UUID gameId) {
|
||||
ReplayGame method = new ReplayGame(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public TableView createTable(UUID roomId, MatchOptions matchOptions) {
|
||||
CreateTable method = new CreateTable(connection, sessionId, roomId, matchOptions);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) {
|
||||
CreateTournamentTable method = new CreateTournamentTable(connection, sessionId, roomId, tournamentOptions);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isTableOwner(UUID roomId, UUID tableId) {
|
||||
IsTableOwner method = new IsTableOwner(connection, sessionId, roomId, tableId);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeTable(UUID roomId, UUID tableId) {
|
||||
RemoveTable method = new RemoveTable(connection, sessionId, roomId, tableId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) {
|
||||
SwapSeats method = new SwapSeats(connection, sessionId, roomId, tableId, seatNum1, seatNum2);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean leaveTable(UUID roomId, UUID tableId) {
|
||||
LeaveTable method = new LeaveTable(connection, sessionId, roomId, tableId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean startGame(UUID roomId, UUID tableId) {
|
||||
StartGame method = new StartGame(connection, sessionId, roomId, tableId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean startTournament(UUID roomId, UUID tableId) {
|
||||
StartTournament method = new StartTournament(connection, sessionId, roomId, tableId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId) {
|
||||
StartChallenge method = new StartChallenge(connection, sessionId, roomId, tableId, challengeId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||
SubmitDeck method = new SubmitDeck(connection, sessionId, tableId, deck);
|
||||
if (handleCall(method))
|
||||
return method.getReturnVal();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean concedeGame(UUID gameId) {
|
||||
ConcedeGame method = new ConcedeGame(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean stopWatching(UUID gameId) {
|
||||
StopWatching method = new StopWatching(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean startReplay(UUID gameId) {
|
||||
StartReplay method = new StartReplay(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean stopReplay(UUID gameId) {
|
||||
StopReplay method = new StopReplay(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean nextPlay(UUID gameId) {
|
||||
NextPlay method = new NextPlay(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean previousPlay(UUID gameId) {
|
||||
PreviousPlay method = new PreviousPlay(connection, sessionId, gameId);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
|
||||
Cheat method = new Cheat(connection, sessionId, gameId, playerId, deckList);
|
||||
return handleCall(method);
|
||||
}
|
||||
|
||||
public void handleServerUnavailable(ServerUnavailable ex) {
|
||||
sessionState = SessionState.SERVER_UNAVAILABLE;
|
||||
logger.fatal("server unavailable - ", ex);
|
||||
disconnect(true);
|
||||
}
|
||||
|
||||
private void handleGameException(GameException ex) {
|
||||
logger.warn(ex.getMessage());
|
||||
client.showError(ex.getMessage());
|
||||
}
|
||||
|
||||
private void handleInvalidDeckException(InvalidDeckException ex) {
|
||||
StringBuilder sbMessage = new StringBuilder();
|
||||
logger.warn(ex.getMessage());
|
||||
sbMessage.append(ex.getMessage()).append("\n");
|
||||
for (Entry<String, String> entry: ex.getInvalid().entrySet()) {
|
||||
sbMessage.append(entry.getKey()).append(":").append(entry.getValue()).append("\n");
|
||||
}
|
||||
client.showError(sbMessage.toString());
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
class ServerPinger implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ping();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MageAuthenticator extends Authenticator {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public MageAuthenticator(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordAuthentication getPasswordAuthentication () {
|
||||
return new PasswordAuthentication (username, password.toCharArray());
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID sessionId;
|
||||
private int messageId;
|
||||
|
||||
public Ack(Connection connection, UUID sessionId, int messageId) {
|
||||
super(connection, "Ack", SessionState.CONNECTED);
|
||||
this.sessionId = sessionId;
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, CallbackException {
|
||||
server.ack(messageId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID sessionId;
|
||||
|
||||
public Callback(Connection connection, UUID sessionId) {
|
||||
super(connection, "Callback", SessionState.CONNECTED);
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientCallback performRemoteCall(Server server) throws RemoteException, CallbackException {
|
||||
return server.callback(sessionId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Cheat extends RemoteMethodCall<Void> {
|
||||
|
||||
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, "Cheat", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ConcedeGame extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public ConcedeGame(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "ConcedeGame", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.concedeGame(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID sessionId;
|
||||
private MatchOptions matchOptions;
|
||||
|
||||
public CreateTable(Connection connection, UUID sessionId, UUID roomId, MatchOptions matchOptions) {
|
||||
super(connection, "CreateTable", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
this.sessionId = sessionId;
|
||||
this.matchOptions = matchOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TableView performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.createTable(sessionId, roomId, matchOptions);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID sessionId;
|
||||
private TournamentOptions tournamentOptions;
|
||||
|
||||
public CreateTournamentTable(Connection connection, UUID sessionId, UUID roomId, TournamentOptions tournamentOptions) {
|
||||
super(connection, "CreateTournamentTable", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
this.sessionId = sessionId;
|
||||
this.tournamentOptions = tournamentOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TableView performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.createTournamentTable(sessionId, roomId, tournamentOptions);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DeregisterClient extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID sessionId;
|
||||
|
||||
public DeregisterClient(Connection connection, UUID sessionId) {
|
||||
super(connection, "DeregisterClient", SessionState.DISCONNECTING);
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.deregisterClient(sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GetConnectedPlayers extends RemoteMethodCall<List<String>> {
|
||||
|
||||
private UUID roomId;
|
||||
|
||||
public GetConnectedPlayers(Connection connection, UUID roomId) {
|
||||
super(connection, "GetConnectedPlayers", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getConnectedPlayers(roomId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GetGameChatId extends RemoteMethodCall<UUID> {
|
||||
|
||||
private UUID gameId;
|
||||
|
||||
public GetGameChatId(Connection connection, UUID gameId) {
|
||||
super(connection, "GetGameChatId", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getGameChatId(gameId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GetMainRoomId extends RemoteMethodCall<UUID> {
|
||||
|
||||
|
||||
public GetMainRoomId(Connection connection) {
|
||||
super(connection, "GetMainRoomId", SessionState.CONNECTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getMainRoomId();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GetRoomChatId extends RemoteMethodCall<UUID> {
|
||||
|
||||
private UUID roomId;
|
||||
|
||||
public GetRoomChatId(Connection connection, UUID roomId) {
|
||||
super(connection, "GetRoomChatId", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getRoomChatId(roomId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
public GetServerState(Connection connection) {
|
||||
super(connection, "GetServerState", SessionState.CONNECTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerState performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getServerState();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
|
||||
public GetTable(Connection connection, UUID roomId, UUID tableId) {
|
||||
super(connection, "GetTable", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TableView performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getTable(roomId, tableId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GetTableChatId extends RemoteMethodCall<UUID> {
|
||||
|
||||
private UUID tableId;
|
||||
|
||||
public GetTableChatId(Connection connection, UUID tableId) {
|
||||
super(connection, "GetTableChatId", SessionState.CONNECTED);
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getTableChatId(tableId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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>> {
|
||||
|
||||
private UUID roomId;
|
||||
|
||||
public GetTables(Connection connection, UUID roomId) {
|
||||
super(connection, "GetTables", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<TableView> performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getTables(roomId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID tournamentId;
|
||||
|
||||
public GetTournament(Connection connection, UUID tournamentId) {
|
||||
super(connection, "GetTournament", SessionState.CONNECTED);
|
||||
this.tournamentId = tournamentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TournamentView performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getTournament(tournamentId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GetTournamentChatId extends RemoteMethodCall<UUID> {
|
||||
|
||||
private UUID tournamentId;
|
||||
|
||||
public GetTournamentChatId(Connection connection, UUID tournamentId) {
|
||||
super(connection, "GetTournamentChatId", SessionState.CONNECTED);
|
||||
this.tournamentId = tournamentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.getTournamentChatId(tournamentId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class IsTableOwner extends RemoteMethodCall<Boolean> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
|
||||
public IsTableOwner(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
|
||||
super(connection, "IsTableOwner", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.isTableOwner(sessionId, roomId, tableId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class JoinChat extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID chatId;
|
||||
private UUID sessionId;
|
||||
private String userName;
|
||||
|
||||
public JoinChat(Connection connection, UUID sessionId, UUID chatId, String userName) {
|
||||
super(connection, "JoinChat", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class JoinDraft extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID draftId;
|
||||
private UUID sessionId;
|
||||
|
||||
public JoinDraft(Connection connection, UUID sessionId, UUID draftId) {
|
||||
super(connection, "JoinDraft", SessionState.CONNECTED);
|
||||
this.draftId = draftId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.joinDraft(draftId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class JoinGame extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public JoinGame(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "JoinGame", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.joinGame(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
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, "JoinTable", SessionState.CONNECTED);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class JoinTournament extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID tournamentId;
|
||||
private UUID sessionId;
|
||||
|
||||
public JoinTournament(Connection connection, UUID sessionId, UUID tournamentId) {
|
||||
super(connection, "JoinTournament", SessionState.CONNECTED);
|
||||
this.tournamentId = tournamentId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.joinTournament(tournamentId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
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, "JoinTournamentTable", SessionState.CONNECTED);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class LeaveChat extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID chatId;
|
||||
private UUID sessionId;
|
||||
|
||||
public LeaveChat(Connection connection, UUID sessionId, UUID chatId) {
|
||||
super(connection, "LeaveChat", SessionState.CONNECTED);
|
||||
this.chatId = chatId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws MageException, RemoteException {
|
||||
server.leaveChat(chatId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class LeaveTable extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
|
||||
public LeaveTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
|
||||
super(connection, "LeaveTable", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class NextPlay extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public NextPlay(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "NextPlay", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.nextPlay(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Ping extends RemoteMethodCall<Boolean> {
|
||||
|
||||
private UUID sessionId;
|
||||
|
||||
public Ping(Connection connection, UUID sessionId) {
|
||||
super(connection, "Ping", SessionState.CONNECTED);
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.ping(sessionId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class PreviousPlay extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public PreviousPlay(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "PreviousPlay", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.previousPlay(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private String userName;
|
||||
private UUID clientId;
|
||||
private MageVersion version;
|
||||
|
||||
public RegisterClient(Connection connection, String userName, UUID clientId, MageVersion version) {
|
||||
super(connection, "RegisterClient", SessionState.CONNECTING);
|
||||
this.userName = userName;
|
||||
this.clientId = clientId;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UUID performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.registerClient(userName, clientId, version);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class RemoveTable extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
|
||||
public RemoveTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
|
||||
super(connection, "RemoveTable", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class ReplayGame extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public ReplayGame(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "ReplayGame", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.replayGame(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID draftId;
|
||||
private UUID cardId;
|
||||
|
||||
public SendCardPick(Connection connection, UUID sessionId, UUID draftId, UUID cardId) {
|
||||
super(connection, "SendCardPick", SessionState.CONNECTED);
|
||||
this.sessionId = sessionId;
|
||||
this.draftId = draftId;
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DraftPickView performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.sendCardPick(draftId, sessionId, cardId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SendChatMessage extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID chatId;
|
||||
private String message;
|
||||
private String userName;
|
||||
|
||||
public SendChatMessage(Connection connection, UUID chatId, String message, String userName) {
|
||||
super(connection, "SendChatMessage", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SendPlayerBoolean extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID gameId;
|
||||
private Boolean data;
|
||||
|
||||
public SendPlayerBoolean(Connection connection, UUID sessionId, UUID gameId, Boolean data) {
|
||||
super(connection, "SendPlayerBoolean", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SendPlayerInteger extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID gameId;
|
||||
private Integer data;
|
||||
|
||||
public SendPlayerInteger(Connection connection, UUID sessionId, UUID gameId, Integer data) {
|
||||
super(connection, "SendPlayerInteger", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SendPlayerString extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID gameId;
|
||||
private String data;
|
||||
|
||||
public SendPlayerString(Connection connection, UUID sessionId, UUID gameId, String data) {
|
||||
super(connection, "SendPlayerString", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SendPlayerUUID extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID sessionId;
|
||||
private UUID gameId;
|
||||
private UUID data;
|
||||
|
||||
public SendPlayerUUID(Connection connection, UUID sessionId, UUID gameId, UUID data) {
|
||||
super(connection, "SendPlayerUUID", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class StartChallenge extends RemoteMethodCall<Void> {
|
||||
|
||||
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, "StartChallenge", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class StartGame extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
|
||||
public StartGame(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
|
||||
super(connection, "StartGame", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class StartReplay extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public StartReplay(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "StartReplay", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.startReplay(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class StartTournament extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
|
||||
public StartTournament(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
|
||||
super(connection, "StartTournament", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class StopReplay extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public StopReplay(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "StopReplay", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.stopReplay(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class StopWatching extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public StopWatching(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "StopWatching", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.stopWatching(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
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> {
|
||||
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
private DeckCardLists deckList;
|
||||
|
||||
public SubmitDeck(Connection connection, UUID sessionId, UUID tableId, DeckCardLists deckList) {
|
||||
super(connection, "SubmitDeck", SessionState.CONNECTED);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class SwapSeats extends RemoteMethodCall<Void> {
|
||||
|
||||
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, "SwapSeats", SessionState.CONNECTED);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class WatchGame extends RemoteMethodCall<Void> {
|
||||
|
||||
private UUID gameId;
|
||||
private UUID sessionId;
|
||||
|
||||
public WatchGame(Connection connection, UUID sessionId, UUID gameId) {
|
||||
super(connection, "WatchGame", SessionState.CONNECTED);
|
||||
this.gameId = gameId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
server.watchGame(gameId, sessionId);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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.constants.Constants.SessionState;
|
||||
import mage.interfaces.Server;
|
||||
import mage.remote.Connection;
|
||||
import mage.remote.RemoteMethodCall;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class WatchTable extends RemoteMethodCall<Boolean> {
|
||||
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private UUID sessionId;
|
||||
|
||||
public WatchTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
|
||||
super(connection, "WatchTable", SessionState.CONNECTED);
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean performRemoteCall(Server server) throws RemoteException, MageException {
|
||||
return server.watchTable(sessionId, roomId, tableId);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,11 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.remote;
|
||||
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
import java.rmi.registry.Registry;
|
||||
import mage.interfaces.Server;
|
||||
package mage.utils;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -48,35 +44,6 @@ 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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return host + ":" + Integer.toString(port);
|
||||
}
|
||||
|
||||
public ProxyType getProxyType() {
|
||||
return proxyType;
|
||||
}
|
|
@ -101,10 +101,6 @@ public class Session {
|
|||
frame.setStatusText("Connected to " + serverName + ":" + port + " ");
|
||||
frame.enableButtons();
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
logger.fatal("", ex);
|
||||
disconnect();
|
||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
||||
} catch (RemoteException ex) {
|
||||
logger.fatal("Unable to connect to server - ", ex);
|
||||
disconnect();
|
||||
|
|
|
@ -82,11 +82,7 @@ public class ChatSession {
|
|||
for (UUID sessionId: clients.keySet()) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null)
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("broadcast error", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
|
||||
else
|
||||
kill(sessionId);
|
||||
}
|
||||
|
|
|
@ -38,16 +38,13 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.logging.Level;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.game.GameException;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.InvalidDeckException;
|
||||
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;
|
||||
|
@ -108,8 +105,8 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void ack(int messageId, UUID sessionId) throws RemoteException, CallbackException {
|
||||
SessionManager.getInstance().getSession(sessionId).ack(messageId);
|
||||
public void ack(String message, UUID sessionId) throws RemoteException, MageException {
|
||||
SessionManager.getInstance().getSession(sessionId).ack(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -212,13 +209,9 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
catch (InvalidDeckException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (GameException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ex instanceof GameException)
|
||||
throw (GameException)ex;
|
||||
handleException(ex);
|
||||
}
|
||||
return false;
|
||||
|
@ -233,10 +226,9 @@ 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,12 +30,7 @@ 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;
|
||||
|
@ -55,12 +50,11 @@ 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();
|
||||
|
@ -90,10 +84,6 @@ public class Session {
|
|||
}
|
||||
|
||||
public void kill() {
|
||||
this.killed = true;
|
||||
synchronized(ackResponse) {
|
||||
ackResponse.notify();
|
||||
}
|
||||
SessionManager.getInstance().removeSession(sessionId);
|
||||
TableManager.getInstance().removeSession(sessionId);
|
||||
GameManager.getInstance().removeSession(sessionId);
|
||||
|
@ -109,116 +99,55 @@ public class Session {
|
|||
return null;
|
||||
}
|
||||
|
||||
public synchronized void fireCallback(final ClientCallback call) throws CallbackException {
|
||||
public synchronized void fireCallback(final ClientCallback call) {
|
||||
call.setMessageId(messageId++);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(sessionId + " - " + call.getMessageId() + " - " + call.getMethod());
|
||||
try {
|
||||
int retryCount = 0;
|
||||
while (retryCount < 3) {
|
||||
callback.setCallback(call);
|
||||
if (waitForAck(call.getMessageId()))
|
||||
return;
|
||||
retryCount++;
|
||||
try {
|
||||
Thread.sleep(2000 * retryCount);
|
||||
}
|
||||
catch (InterruptedException ignored) {}
|
||||
}
|
||||
callback.setCallback(call);
|
||||
} 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) 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 gameStarted(final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, 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 draftStarted(final UUID draftId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, 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 tournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||
}
|
||||
|
||||
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 sideboard(final Deck deck, final UUID tableId, final int time) {
|
||||
fireCallback(new ClientCallback("sideboard", 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 construct(final Deck deck, final UUID tableId, final int time) {
|
||||
fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time)));
|
||||
}
|
||||
|
||||
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 watchGame(final UUID gameId) {
|
||||
fireCallback(new ClientCallback("watchGame", gameId));
|
||||
}
|
||||
|
||||
public void replayGame(final UUID gameId) {
|
||||
try {
|
||||
fireCallback(new ClientCallback("replayGame", gameId));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("replayGame exception", ex);
|
||||
}
|
||||
fireCallback(new ClientCallback("replayGame", gameId));
|
||||
}
|
||||
|
||||
public void ack(int messageId) {
|
||||
synchronized(ackResponse) {
|
||||
ackResponse.setAck(true);
|
||||
ackResponse.setValue(messageId);
|
||||
ackResponse.notify();
|
||||
}
|
||||
public void ack(String message) {
|
||||
this.ackMessage = message;
|
||||
}
|
||||
|
||||
public String getAckMessage() {
|
||||
return ackMessage;
|
||||
}
|
||||
|
||||
public void clearAck() {
|
||||
this.ackMessage = "";
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
|
|
@ -209,13 +209,8 @@ public class TableController {
|
|||
if (table.getState() != TableState.DUELING) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
SessionManager.getInstance().getSession(sessionId).watchGame(match.getGame().getId());
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
logger.fatal("watchTable error", ex);
|
||||
}
|
||||
return false;
|
||||
SessionManager.getInstance().getSession(sessionId).watchGame(match.getGame().getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean replayTable(UUID sessionId) {
|
||||
|
@ -341,12 +336,8 @@ public class TableController {
|
|||
table.initDraft();
|
||||
DraftManager.getInstance().createDraftSession(draft, sessionPlayerMap, table.getId());
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
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);
|
||||
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
sessionManager.getSession(entry.getKey()).draftStarted(draft.getId(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,13 +72,8 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftInit", draft.getId(), draftView));
|
||||
return true;
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("Unable to start draft ", ex);
|
||||
return false;
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftInit", draft.getId(), draftView));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -96,11 +91,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftUpdate", draft.getId(), draftView));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("update draft exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftUpdate", draft.getId(), draftView));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,11 +100,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(draftView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draft inform exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(draftView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,11 +109,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftOver", draft.getId()));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draft end exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftOver", draft.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,11 +119,7 @@ public class DraftSession {
|
|||
setupTimeout(timeout);
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(draftPickView)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draft pick exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(draftPickView)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,11 +71,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(gameView, question)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game ask exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(gameView, question)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +81,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(gameView, question, cardView, targets, required, options)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,11 +91,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(gameView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game select exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +101,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game choose ability exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,11 +111,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[0]), message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,11 +121,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,11 +131,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,11 +141,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,11 +150,7 @@ public class GameSession extends GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game reveal exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue