From 8b1c463d35fd17c83b362b524b88ffe357db4717 Mon Sep 17 00:00:00 2001
From: BetaSteward <betasteward@gmail>
Date: Tue, 31 May 2011 23:01:07 -0400
Subject: [PATCH] big client update - moved Session to Mage.Common project,
 this will allow other clients to reuse connection logic

---
 .../src/main/java/mage/client/MageFrame.java  | 106 +++-
 .../src/main/java/mage/client/cards/Card.java |   6 +-
 .../main/java/mage/client/chat/ChatPanel.java |  11 +-
 .../java/mage/client/dialog/AboutDialog.form  |   2 +-
 .../java/mage/client/dialog/AboutDialog.java  |   5 +-
 .../mage/client/dialog/JoinTableDialog.java   |   2 +-
 .../mage/client/dialog/NewTableDialog.java    |   4 +-
 .../client/dialog/NewTournamentDialog.java    |   2 +-
 .../mage/client/dialog/ReconnectDialog.java   |   2 +-
 .../client/dialog/TableWaitingDialog.form     |   3 +-
 .../client/dialog/TableWaitingDialog.java     |   4 +-
 .../java/mage/client/draft/DraftPanel.java    |   4 +-
 .../java/mage/client/game/AbilityPicker.java  |   2 +-
 .../java/mage/client/game/FeedbackPanel.java  |   2 +-
 .../main/java/mage/client/game/GamePanel.java |   8 +-
 .../java/mage/client/game/PlayerPanel.java    |   2 +-
 .../java/mage/client/game/PlayerPanelExt.java |   2 +-
 .../plugins/adapters/MageActionCallback.java  |  16 +-
 .../{Client.java => CallbackClientImpl.java}  |  53 +-
 .../mage/client/table/TablePlayerPanel.java   |   2 +-
 .../java/mage/client/table/TablesPanel.java   |   8 +-
 .../client/table/TournamentPlayerPanel.java   |   2 +-
 .../client/tournament/TournamentPanel.java    |   6 +-
 .../client/util/DefaultActionCallback.java    |   2 +-
 .../mage/client/game/StartMultiGamesTest.java |   2 +-
 Mage.Common/src/mage/constants/Constants.java |   5 +
 Mage.Common/src/mage/interfaces/Client.java   |  48 ++
 .../callback/CallbackClientDaemon.java        |   1 +
 .../src/mage}/remote/MageRemoteException.java |   2 +-
 .../src/mage/remote/RMIClientDaemon.java      |   2 -
 .../src/mage/remote/RemoteMethodCall.java     |  15 +-
 .../src/mage}/remote/Session.java             | 552 +++---------------
 Mage.Common/src/mage/remote/method/Ack.java   |   3 +-
 .../src/mage/remote/method/Callback.java      |   3 +-
 Mage.Common/src/mage/remote/method/Cheat.java |   3 +-
 .../src/mage/remote/method/ConcedeGame.java   |   3 +-
 .../src/mage/remote/method/CreateTable.java   |   3 +-
 .../remote/method/CreateTournamentTable.java  |   3 +-
 .../mage/remote/method/DeregisterClient.java  |   3 +-
 .../remote/method/GetConnectedPlayers.java    |   3 +-
 .../src/mage/remote/method/GetGameChatId.java |   3 +-
 .../src/mage/remote/method/GetMainRoomId.java |   3 +-
 .../src/mage/remote/method/GetRoomChatId.java |   3 +-
 .../mage/remote/method/GetServerState.java    |   3 +-
 .../src/mage/remote/method/GetTable.java      |   3 +-
 .../mage/remote/method/GetTableChatId.java    |   3 +-
 .../src/mage/remote/method/GetTables.java     |   3 +-
 .../src/mage/remote/method/GetTournament.java |   3 +-
 .../remote/method/GetTournamentChatId.java    |   3 +-
 .../src/mage/remote/method/IsTableOwner.java  |   3 +-
 .../src/mage/remote/method/JoinChat.java      |   3 +-
 .../src/mage/remote/method/JoinDraft.java     |   3 +-
 .../src/mage/remote/method/JoinGame.java      |   3 +-
 .../src/mage/remote/method/JoinTable.java     |   3 +-
 .../mage/remote/method/JoinTournament.java    |   3 +-
 .../remote/method/JoinTournamentTable.java    |   3 +-
 .../src/mage/remote/method/LeaveChat.java     |   3 +-
 .../src/mage/remote/method/LeaveTable.java    |   3 +-
 .../src/mage/remote/method/NextPlay.java      |   3 +-
 Mage.Common/src/mage/remote/method/Ping.java  |   3 +-
 .../src/mage/remote/method/PreviousPlay.java  |   3 +-
 .../mage/remote/method/RegisterClient.java    |   3 +-
 .../src/mage/remote/method/RemoveTable.java   |   3 +-
 .../src/mage/remote/method/ReplayGame.java    |   3 +-
 .../src/mage/remote/method/SendCardPick.java  |   3 +-
 .../mage/remote/method/SendChatMessage.java   |   3 +-
 .../mage/remote/method/SendPlayerBoolean.java |   3 +-
 .../mage/remote/method/SendPlayerInteger.java |   3 +-
 .../mage/remote/method/SendPlayerString.java  |   3 +-
 .../mage/remote/method/SendPlayerUUID.java    |   3 +-
 .../mage/remote/method/StartChallenge.java    |   3 +-
 .../src/mage/remote/method/StartGame.java     |   3 +-
 .../src/mage/remote/method/StartReplay.java   |   3 +-
 .../mage/remote/method/StartTournament.java   |   3 +-
 .../src/mage/remote/method/StopReplay.java    |   3 +-
 .../src/mage/remote/method/StopWatching.java  |   3 +-
 .../src/mage/remote/method/SubmitDeck.java    |   3 +-
 .../src/mage/remote/method/SwapSeats.java     |   3 +-
 .../src/mage/remote/method/WatchGame.java     |   3 +-
 .../src/mage/remote/method/WatchTable.java    |   3 +-
 80 files changed, 417 insertions(+), 610 deletions(-)
 rename Mage.Client/src/main/java/mage/client/remote/{Client.java => CallbackClientImpl.java} (85%)
 create mode 100644 Mage.Common/src/mage/interfaces/Client.java
 rename {Mage.Client/src/main/java/mage/client => Mage.Common/src/mage}/remote/MageRemoteException.java (98%)
 rename {Mage.Client/src/main/java/mage/client => Mage.Common/src/mage}/remote/Session.java (55%)

diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java
index 1c4b763ee5..8502d43a83 100644
--- a/Mage.Client/src/main/java/mage/client/MageFrame.java
+++ b/Mage.Client/src/main/java/mage/client/MageFrame.java
@@ -46,7 +46,8 @@ 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.client.remote.Session;
+import mage.interfaces.callback.ClientCallback;
+import mage.remote.Session;
 import mage.client.util.EDTExceptionHandler;
 import mage.client.util.gui.ArrowBuilder;
 import mage.components.ImagePanel;
@@ -72,13 +73,21 @@ 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.remote.Session.SessionState;
+import mage.client.game.GamePanel;
+import mage.client.remote.CallbackClientImpl;
 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;
@@ -89,16 +98,24 @@ import org.apache.log4j.Logger;
 /**
  * @author BetaSteward_at_googlemail.com
  */
-public class MageFrame extends javax.swing.JFrame {
+public class MageFrame extends javax.swing.JFrame implements Client {
 
     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;
     private Rectangle titleRectangle;
 	private final static MageVersion version = new MageVersion(0, 7, 3);
+	private UUID clientId;
+	
+	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();
 
     /**
      * @return the session
@@ -115,7 +132,8 @@ public class MageFrame extends javax.swing.JFrame {
         return prefs;
     }
 
-	public static MageVersion getVersion() {
+	@Override
+	public MageVersion getVersion() {
 		return version;
 	}
 
@@ -125,7 +143,8 @@ public class MageFrame extends javax.swing.JFrame {
     public MageFrame() {
 
         setTitle("Mage, version " + version);
-
+		clientId = UUID.randomUUID();
+		
         EDTExceptionHandler.registerExceptionHandler();
         addWindowListener(new WindowAdapter() {
             @Override
@@ -151,9 +170,10 @@ public class MageFrame extends javax.swing.JFrame {
         this.setExtendedState(JFrame.MAXIMIZED_BOTH);
 
         session = new Session(this);
+		callbackClient = new CallbackClientImpl(this);
         connectDialog = new ConnectDialog();
         desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
-        session.getUI().addComponent(MageComponents.DESKTOP_PANE, desktopPane);
+        ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
 
 		try {
 			tablesPane = new TablesPane();
@@ -240,7 +260,7 @@ public class MageFrame extends javax.swing.JFrame {
             label.setBounds(0, 0, 180, 30);
         }
 
-        session.getUI().addButton(MageComponents.TABLES_MENU_BUTTON, btnGames);
+        ui.addButton(MageComponents.TABLES_MENU_BUTTON, btnGames);
 
         SwingUtilities.invokeLater(new Runnable() {
             public void run() {
@@ -272,8 +292,8 @@ public class MageFrame extends javax.swing.JFrame {
 
         desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER);
 
-        session.getUI().addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
-        session.getUI().addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
+        ui.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
+        ui.addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
     }
 
     private void setBackground() {
@@ -723,7 +743,7 @@ public class MageFrame extends javax.swing.JFrame {
     private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed
         AboutDialog aboutDialog = new AboutDialog();
         desktopPane.add(aboutDialog);
-        aboutDialog.showDialog();
+        aboutDialog.showDialog(version);
     }//GEN-LAST:event_btnAboutActionPerformed
 
     public void exitApp() {
@@ -842,6 +862,72 @@ public class MageFrame extends javax.swing.JFrame {
         this.lblStatus.setText(status);
     }
 
+	public static MageUI getUI() {
+		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(String message) {
+		setStatusText(message);
+		enableButtons();
+	}
+
+	@Override
+	public void disconnected() {
+		setStatusText("Not connected");
+		disableButtons();
+		hideGames();
+		hideTables();
+	}
+
+	@Override
+	public void showMessage(String message) {
+		JOptionPane.showMessageDialog(desktopPane, message);
+	}
+
+	@Override
+	public void showError(String message) {
+		JOptionPane.showMessageDialog(desktopPane, message, "Error", JOptionPane.ERROR_MESSAGE);
+	}
+
+	@Override
+	public void processCallback(ClientCallback callback) {
+		callbackClient.processCallback(callback);
+	}
+
 }
 
 class MagePaneMenuItem extends JCheckBoxMenuItem {
diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java
index ad229651b1..96b2e2fdb0 100644
--- a/Mage.Client/src/main/java/mage/client/cards/Card.java
+++ b/Mage.Client/src/main/java/mage/client/cards/Card.java
@@ -80,7 +80,7 @@ import mage.cards.MagePermanent;
 import mage.cards.TextPopup;
 import mage.client.MageFrame;
 import mage.client.game.PlayAreaPanel;
-import mage.client.remote.Session;
+import mage.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 = session.getGame(gameId).getPlayers().get(uuid);
+					PlayAreaPanel p = MageFrame.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 : session.getGame(gameId).getPlayers().values()) {
+						for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
 							MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
 							if (permanent != null) {
 								Point target = permanent.getLocationOnScreen();
diff --git a/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java b/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java
index ad0e6e3eaf..6347ba7181 100644
--- a/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java
+++ b/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java
@@ -39,11 +39,10 @@ import java.awt.event.KeyEvent;
 import java.util.*;
 import java.util.List;
 import mage.client.MageFrame;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.view.ChatMessage.MessageColor;
 
 import javax.swing.table.AbstractTableModel;
-import mage.client.remote.Session.SessionState;
 
 /**
  *
@@ -52,7 +51,6 @@ import mage.client.remote.Session.SessionState;
 public class ChatPanel extends javax.swing.JPanel {
 
 	private UUID chatId;
-	private UUID clientId;
 	private Session session;
 
 	private List<String> players = new ArrayList<String>();
@@ -76,12 +74,13 @@ public class ChatPanel extends javax.swing.JPanel {
 	public void connect(UUID chatId) {
 		session = MageFrame.getSession();
 		this.chatId = chatId;
-		session.joinChat(chatId, this);
+		if (session.joinChat(chatId)) {
+			MageFrame.addChat(chatId, this);
+		}
 	}
 
 	public void disconnect() {
-		if (session != null && session.getState() == SessionState.CONNECTED)
-			session.leaveChat(chatId);
+		session.leaveChat(chatId);
 	}
 
 	public void receiveMessage(String message, MessageColor color) {
diff --git a/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.form b/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.form
index f455c8f505..68504fc0ae 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.form
+++ b/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.form
@@ -49,7 +49,7 @@
               <EmptySpace max="-2" attributes="0"/>
               <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
               <EmptySpace max="-2" attributes="0"/>
-              <Component id="jLabel3" pref="44" max="32767" attributes="0"/>
+              <Component id="jLabel3" pref="48" max="32767" attributes="0"/>
               <EmptySpace type="separate" max="-2" attributes="0"/>
               <Component id="btnOk" min="-2" max="-2" attributes="0"/>
               <EmptySpace max="-2" attributes="0"/>
diff --git a/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.java b/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.java
index 74d257c4b0..1c3fc33f2a 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/AboutDialog.java
@@ -35,6 +35,7 @@
 package mage.client.dialog;
 
 import mage.client.MageFrame;
+import mage.utils.MageVersion;
 
 /**
  *
@@ -48,8 +49,8 @@ public class AboutDialog extends MageDialog {
 		this.modal = false;
     }
 
-	public void showDialog() {
-		this.lblVersion.setText(MageFrame.getVersion().toString());
+	public void showDialog(MageVersion version) {
+		this.lblVersion.setText(version.toString());
 		this.setLocation(100, 100);
 		this.setVisible(true);
 	}
diff --git a/Mage.Client/src/main/java/mage/client/dialog/JoinTableDialog.java b/Mage.Client/src/main/java/mage/client/dialog/JoinTableDialog.java
index 064632996d..cc9a2fbb58 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/JoinTableDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/JoinTableDialog.java
@@ -38,7 +38,7 @@ package mage.client.dialog;
 import mage.client.*;
 import java.util.UUID;
 import javax.swing.JOptionPane;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.sets.Sets;
 import org.apache.log4j.Logger;
 
diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java
index d447e02dab..34e8a773ae 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java
@@ -46,7 +46,7 @@ import javax.swing.SpinnerNumberModel;
 import mage.Constants.MultiplayerAttackOption;
 import mage.Constants.RangeOfInfluence;
 import mage.client.components.MageComponents;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.table.TablePlayerPanel;
 import mage.client.util.Event;
 import mage.client.util.Listener;
@@ -410,7 +410,7 @@ public class NewTableDialog extends MageDialog {
 
 	public void showDialog(UUID roomId) {
 		session = MageFrame.getSession();
-		session.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
+		MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
 		this.player1Panel.setPlayerName(session.getUserName());
 		cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
 		cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java
index c11d1cf383..322260b5fe 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java
@@ -45,7 +45,7 @@ import mage.Constants.MultiplayerAttackOption;
 import mage.Constants.RangeOfInfluence;
 import mage.cards.ExpansionSet;
 import mage.client.MageFrame;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.table.TournamentPlayerPanel;
 import mage.game.draft.DraftOptions;
 import mage.game.draft.DraftOptions.TimingOption;
diff --git a/Mage.Client/src/main/java/mage/client/dialog/ReconnectDialog.java b/Mage.Client/src/main/java/mage/client/dialog/ReconnectDialog.java
index efa5915d06..5ae9d3522d 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/ReconnectDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/ReconnectDialog.java
@@ -37,7 +37,7 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.SwingWorker;
-import mage.client.remote.Session;
+import mage.remote.Session;
 
 /**
  *
diff --git a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form
index 912e797bc6..d0387c5654 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form
+++ b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form
@@ -2,7 +2,6 @@
 
 <Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
   <Properties>
-    <Property name="closable" type="boolean" value="false"/>
     <Property name="resizable" type="boolean" value="true"/>
     <Property name="title" type="java.lang.String" value="Waiting for players"/>
   </Properties>
@@ -41,7 +40,7 @@
     <DimensionLayout dim="1">
       <Group type="103" groupAlignment="0" attributes="0">
           <Group type="102" attributes="0">
-              <Component id="jSplitPane1" pref="267" max="32767" attributes="0"/>
+              <Component id="jSplitPane1" pref="271" 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"/>
diff --git a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java
index 1b075c680f..9cc9e6b382 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java
@@ -40,7 +40,7 @@ import java.util.UUID;
 import javax.swing.SwingWorker;
 import javax.swing.table.AbstractTableModel;
 import mage.client.components.MageComponents;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.view.SeatView;
 import mage.view.TableView;
 import org.apache.log4j.Logger;
@@ -69,7 +69,7 @@ public class TableWaitingDialog extends MageDialog {
 		initComponents();
 
 		tableSeats.createDefaultColumnsFromModel();
-		session.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
+		MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
     }
 
 	public void update(TableView table) {
diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java
index 19e12351e9..b15ebc471f 100644
--- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java
+++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java
@@ -41,7 +41,7 @@ import java.util.UUID;
 import javax.swing.Timer;
 import mage.client.MageFrame;
 import mage.client.constants.Constants.SortBy;
-import mage.client.remote.Session;
+import mage.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();
-		session.addDraft(draftId, this);
+		MageFrame.addDraft(draftId, this);
 		if (!session.joinDraft(draftId))
 			hideDraft();
 	}
diff --git a/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java b/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java
index b9d027a6ee..b521cb0c92 100644
--- a/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java
+++ b/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java
@@ -38,7 +38,7 @@ import javax.swing.JPopupMenu;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 import mage.client.MageFrame;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.util.gui.GuiDisplayUtil;
 import mage.view.AbilityPickerView;
 
diff --git a/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java b/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java
index 41c7c8ec95..b896c75213 100644
--- a/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java
+++ b/Mage.Client/src/main/java/mage/client/game/FeedbackPanel.java
@@ -49,7 +49,7 @@ import javax.swing.SwingUtilities;
 
 import mage.client.MageFrame;
 import mage.client.components.MageTextArea;
-import mage.client.remote.Session;
+import mage.remote.Session;
 
 import org.apache.log4j.Logger;
 
diff --git a/Mage.Client/src/main/java/mage/client/game/GamePanel.java b/Mage.Client/src/main/java/mage/client/game/GamePanel.java
index d38f40fbb4..762af4a87f 100644
--- a/Mage.Client/src/main/java/mage/client/game/GamePanel.java
+++ b/Mage.Client/src/main/java/mage/client/game/GamePanel.java
@@ -57,7 +57,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.client.remote.Session;
+import mage.remote.Session;
 import mage.client.util.Config;
 import mage.client.util.GameManager;
 import mage.client.util.PhaseManager;
@@ -153,7 +153,7 @@ public class GamePanel extends javax.swing.JPanel {
 		this.gameId = gameId;
 		this.playerId = playerId;
 		session = MageFrame.getSession();
-		session.addGame(gameId, this);
+		MageFrame.addGame(gameId, this);
 		this.feedbackPanel.init(gameId);
 		this.feedbackPanel.clear();
 		this.abilityPicker.init(session, gameId);
@@ -171,7 +171,7 @@ public class GamePanel extends javax.swing.JPanel {
 		this.gameId = gameId;
 		this.playerId = null;
 		session = MageFrame.getSession();
-		session.addGame(gameId, this);
+		MageFrame.addGame(gameId, this);
 		this.feedbackPanel.init(gameId);
 		this.feedbackPanel.clear();
 		this.btnConcede.setVisible(false);
@@ -188,7 +188,7 @@ public class GamePanel extends javax.swing.JPanel {
 		this.gameId = gameId;
 		this.playerId = null;
 		session = MageFrame.getSession();
-		session.addGame(gameId, this);
+		MageFrame.addGame(gameId, this);
 		this.feedbackPanel.clear();
 		this.btnConcede.setVisible(false);
 		this.btnStopWatching.setVisible(false);
diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanel.java
index eef67591d1..5b0be1560a 100644
--- a/Mage.Client/src/main/java/mage/client/game/PlayerPanel.java
+++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanel.java
@@ -39,7 +39,7 @@ import java.util.UUID;
 import mage.client.MageFrame;
 import mage.client.cards.BigCard;
 import mage.client.dialog.ShowCardsDialog;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.util.Config;
 import mage.view.PlayerView;
 
diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java
index eb08f65704..0473c49e08 100644
--- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java
+++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java
@@ -42,7 +42,7 @@ import mage.client.components.arcane.GlowText;
 import mage.client.components.arcane.ManaSymbols;
 import mage.client.components.arcane.UI;
 import mage.client.dialog.ShowCardsDialog;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.util.Command;
 import mage.client.util.Config;
 import mage.client.util.ImageHelper;
diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java
index 1c0eb45238..9cf54c1aec 100644
--- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java
+++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java
@@ -21,7 +21,7 @@ import mage.client.components.MageComponents;
 import mage.client.components.MageRoundPane;
 import mage.client.game.PlayAreaPanel;
 import mage.client.plugins.impl.Plugins;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.util.DefaultActionCallback;
 import mage.client.util.ImageHelper;
 import mage.client.util.gui.ArrowBuilder;
@@ -85,13 +85,13 @@ public class MageActionCallback implements ActionCallback {
             for (UUID uuid : targets) {
                 //System.out.println("Getting play area panel for uuid: " + uuid);
 
-                PlayAreaPanel p = session.getGame(data.gameId).getPlayers().get(uuid);
+                PlayAreaPanel p = MageFrame.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 : session.getGame(data.gameId).getPlayers().values()) {
+                    for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
                         MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
                         if (permanent != null) {
                             Point target = permanent.getLocationOnScreen();
@@ -108,7 +108,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 : session.getGame(data.gameId).getPlayers().values()) {
+            for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
                 MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
                 if (permanent != null) {
                     Point source = permanent.getLocationOnScreen();
@@ -149,15 +149,15 @@ public class MageActionCallback implements ActionCallback {
                         if (session == null || !state) {
                             return;
                         }
-                        final Component popupContainer = session.getUI().getComponent(MageComponents.POPUP_CONTAINER);
-                        Component popup2 = session.getUI().getComponent(MageComponents.CARD_INFO_PANE);
+                        final Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
+                        Component popup2 = MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
                         ((CardInfoPane) popup2).setCard(data.card);
                         Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
                         location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, popup2, parentComponent);
                         location.translate(-parentPoint.x, -parentPoint.y);
                         popupContainer.setLocation(location);
                         ThreadUtils.sleep(200);
-                        final Component c = session.getUI().getComponent(MageComponents.DESKTOP_PANE);
+                        final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
                         SwingUtilities.invokeLater(new Runnable() {
                             @Override
                             public void run() {
@@ -227,7 +227,7 @@ public class MageActionCallback implements ActionCallback {
             if (session == null) {
                 return;
             }
-            Component popupContainer = session.getUI().getComponent(MageComponents.POPUP_CONTAINER);
+            Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
             popupContainer.setVisible(false);
         } catch (Exception e2) {
             e2.printStackTrace();
diff --git a/Mage.Client/src/main/java/mage/client/remote/Client.java b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java
similarity index 85%
rename from Mage.Client/src/main/java/mage/client/remote/Client.java
rename to Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java
index 4fb8ccbf37..618bb7f768 100644
--- a/Mage.Client/src/main/java/mage/client/remote/Client.java
+++ b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java
@@ -28,6 +28,7 @@
 
 package mage.client.remote;
 
+import mage.remote.Session;
 import java.rmi.RemoteException;
 import java.util.UUID;
 import javax.swing.JOptionPane;
@@ -55,20 +56,18 @@ import org.apache.log4j.Logger;
  *
  * @author BetaSteward_at_googlemail.com
  */
-public class Client implements CallbackClient {
+public class CallbackClientImpl implements CallbackClient {
 
-	private final static Logger logger = Logger.getLogger(Client.class);
+	private final static Logger logger = Logger.getLogger(CallbackClientImpl.class);
 
 	private UUID clientId;
 	private MageFrame frame;
-	private Session session;
 	private int messageId = 0;
 
-	public Client(Session session, MageFrame frame) {
+	public CallbackClientImpl(MageFrame frame) {
 
 		this.clientId = UUID.randomUUID();
 		this.frame = frame;
-		this.session = session;
 
 	}
 
@@ -101,36 +100,36 @@ public class Client implements CallbackClient {
 					}
 					else if (callback.getMethod().equals("chatMessage")) {
 						ChatMessage message = (ChatMessage) callback.getData();
-						ChatPanel panel = session.getChat(callback.getObjectId());
+						ChatPanel panel = frame.getChat(callback.getObjectId());
 						if (panel != null)
 							panel.receiveMessage(message.getMessage(), message.getColor());
 					}
 					else if (callback.getMethod().equals("replayInit")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null)
 							panel.init((GameView) callback.getData());
 					}
 					else if (callback.getMethod().equals("replayDone")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null) {
 							panel.modalMessage((String) callback.getData());
 							panel.hideGame();
 						}
 					}
 					else if (callback.getMethod().equals("replayUpdate")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null)
 							panel.updateGame((GameView) callback.getData());
 					}
 					else if (callback.getMethod().equals("gameInit")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null) {
 							panel.init((GameView) callback.getData());
 
 						}
 					}
 					else if (callback.getMethod().equals("gameOver")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null) {
 							panel.modalMessage((String) callback.getData());
 							panel.hideGame();
@@ -138,53 +137,53 @@ public class Client implements CallbackClient {
 					}
 					else if (callback.getMethod().equals("gameAsk")) {
 						GameClientMessage message = (GameClientMessage) callback.getData();
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.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 = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.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 = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null)
 							panel.select(message.getMessage(), message.getGameView());
 					}
 					else if (callback.getMethod().equals("gameChooseAbility")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null)
 							panel.pickAbility((AbilityPickerView) callback.getData());
 					}
 					else if (callback.getMethod().equals("gameChoose")) {
 						GameClientMessage message = (GameClientMessage) callback.getData();
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.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 = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.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 = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.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 = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null)
 							panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
 					}
 					else if (callback.getMethod().equals("gameUpdate")) {
-						GamePanel panel = session.getGame(callback.getObjectId());
+						GamePanel panel = frame.getGame(callback.getObjectId());
 						if (panel != null)
 							panel.updateGame((GameView) callback.getData());
 					}
@@ -192,7 +191,7 @@ public class Client implements CallbackClient {
 						
 						if (callback.getMessageId() > messageId) {
 							GameClientMessage message = (GameClientMessage) callback.getData();
-							GamePanel panel = session.getGame(callback.getObjectId());
+							GamePanel panel = frame.getGame(callback.getObjectId());
 							if (panel != null)
 								panel.inform(message.getMessage(), message.getGameView());
 						}
@@ -209,18 +208,18 @@ public class Client implements CallbackClient {
 						construct(message.getDeck(), message.getTableId(), message.getTime());
 					}
 					else if (callback.getMethod().equals("draftOver")) {
-						DraftPanel panel = session.getDraft(callback.getObjectId());
+						DraftPanel panel = frame.getDraft(callback.getObjectId());
 						if (panel != null)
 							panel.hideDraft();
 					}
 					else if (callback.getMethod().equals("draftPick")) {
 						DraftClientMessage message = (DraftClientMessage) callback.getData();
-						DraftPanel panel = session.getDraft(callback.getObjectId());
+						DraftPanel panel = frame.getDraft(callback.getObjectId());
 						if (panel != null)
 							panel.loadBooster(message.getDraftPickView());
 					}
 					else if (callback.getMethod().equals("draftUpdate")) {
-						DraftPanel panel = session.getDraft(callback.getObjectId());
+						DraftPanel panel = frame.getDraft(callback.getObjectId());
 						if (panel != null)
 							panel.updateDraft((DraftView) callback.getData());
 					}
@@ -247,7 +246,7 @@ public class Client implements CallbackClient {
 		});
 	}
 
-	public UUID getId() throws RemoteException {
+	public UUID getId() {
 		return clientId;
 	}
 
@@ -315,9 +314,7 @@ public class Client implements CallbackClient {
 
 	private void handleException(Exception ex) {
 		logger.fatal("Client error\n", ex);
-		JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unrecoverable client error.  Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
-		session.disconnect(false);
-		frame.disableButtons();
+		frame.showError("Error: " + ex.getMessage());
 	}
 
 }
diff --git a/Mage.Client/src/main/java/mage/client/table/TablePlayerPanel.java b/Mage.Client/src/main/java/mage/client/table/TablePlayerPanel.java
index 8515206a69..2eb3f7b6cb 100644
--- a/Mage.Client/src/main/java/mage/client/table/TablePlayerPanel.java
+++ b/Mage.Client/src/main/java/mage/client/table/TablePlayerPanel.java
@@ -41,7 +41,7 @@ import java.util.UUID;
 import javax.swing.DefaultComboBoxModel;
 
 import mage.client.MageFrame;
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.client.util.Config;
 import mage.client.util.Event;
 import mage.client.util.Listener;
diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
index b5c24ee1d3..0c6b94c0a6 100644
--- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
+++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
@@ -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.client.remote.MageRemoteException;
-import mage.client.remote.Session;
+import mage.remote.MageRemoteException;
+import mage.remote.Session;
 import mage.client.util.ButtonColumn;
 import mage.game.match.MatchOptions;
 import mage.sets.Sets;
@@ -101,7 +101,7 @@ public class TablesPanel extends javax.swing.JPanel {
 				if (state.equals("Join")) {
 					if (owner.equals(session.getUserName())) {
 						try {
-							JDesktopPane desktopPane = (JDesktopPane)session.getUI().getComponent(MageComponents.DESKTOP_PANE);
+							JDesktopPane desktopPane = (JDesktopPane)MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
 							JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
 							for (JInternalFrame frame : windows) {
 								if (frame.getTitle().equals("Waiting for players")) {
@@ -204,7 +204,7 @@ public class TablesPanel extends javax.swing.JPanel {
 			hideTables();
 		}
 		
-		session.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
+		MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
 	}
 
 	public void hideTables() {
diff --git a/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java b/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java
index 42fdffe889..e4ace620af 100644
--- a/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java
+++ b/Mage.Client/src/main/java/mage/client/table/TournamentPlayerPanel.java
@@ -38,7 +38,7 @@ import java.util.UUID;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JComboBox;
 import mage.client.MageFrame;
-import mage.client.remote.Session;
+import mage.remote.Session;
 
 /**
  *
diff --git a/Mage.Client/src/main/java/mage/client/tournament/TournamentPanel.java b/Mage.Client/src/main/java/mage/client/tournament/TournamentPanel.java
index 0b07398acf..8247afc2d6 100644
--- a/Mage.Client/src/main/java/mage/client/tournament/TournamentPanel.java
+++ b/Mage.Client/src/main/java/mage/client/tournament/TournamentPanel.java
@@ -45,8 +45,8 @@ import java.util.UUID;
 import javax.swing.*;
 import javax.swing.table.AbstractTableModel;
 import mage.client.MageFrame;
-import mage.client.remote.MageRemoteException;
-import mage.client.remote.Session;
+import mage.remote.MageRemoteException;
+import mage.remote.Session;
 import mage.client.util.ButtonColumn;
 import mage.view.RoundView;
 import mage.view.TournamentGameView;
@@ -101,7 +101,7 @@ public class TournamentPanel extends javax.swing.JPanel implements Observer {
 	public synchronized void showTournament(UUID tournamentId) {
 		this.tournamentId = tournamentId;
 		session = MageFrame.getSession();
-		session.addTournament(tournamentId, this);
+		MageFrame.addTournament(tournamentId, this);
 		UUID chatRoomId = session.getTournamentChatId(tournamentId);
 		if (session.joinTournament(tournamentId) && chatRoomId != null) {
 			this.chatPanel1.connect(chatRoomId);
diff --git a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java
index 7a7421af71..e783ad9f5b 100644
--- a/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java
+++ b/Mage.Client/src/main/java/mage/client/util/DefaultActionCallback.java
@@ -3,7 +3,7 @@ package mage.client.util;
 import java.awt.event.MouseEvent;
 import java.util.UUID;
 
-import mage.client.remote.Session;
+import mage.remote.Session;
 import mage.view.CardView;
 
 
diff --git a/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java b/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java
index 21f3fb21f9..9188f86f5e 100644
--- a/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java
+++ b/Mage.Client/src/test/java/mage/client/game/StartMultiGamesTest.java
@@ -56,7 +56,7 @@ public class StartMultiGamesTest {
 			if (frame == null) {
 				sync.wait();
 			}
-			ui = MageFrame.getSession().getUI();
+			ui = MageFrame.getUI();
 			ui.doClick(MageComponents.TABLES_MENU_BUTTON);
 			ui.doClick(MageComponents.NEW_GAME_BUTTON);
 			ui.doClick(MageComponents.NEW_TABLE_OK_BUTTON, 500);
diff --git a/Mage.Common/src/mage/constants/Constants.java b/Mage.Common/src/mage/constants/Constants.java
index 5868f1f643..8ae7439c03 100644
--- a/Mage.Common/src/mage/constants/Constants.java
+++ b/Mage.Common/src/mage/constants/Constants.java
@@ -69,4 +69,9 @@ public final class Constants {
 	public static final double SCALE_FACTOR = 0.5;
 	
 	public static final String PLUGINS_DIRECTORY = "plugins/";
+	
+	public enum SessionState {
+		DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_UNAVAILABLE;
+	}
+
 }
diff --git a/Mage.Common/src/mage/interfaces/Client.java b/Mage.Common/src/mage/interfaces/Client.java
new file mode 100644
index 0000000000..a6094843ed
--- /dev/null
+++ b/Mage.Common/src/mage/interfaces/Client.java
@@ -0,0 +1,48 @@
+/*
+* 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);
+	
+}
diff --git a/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java b/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java
index f1da51619b..ff0e2b6a2c 100644
--- a/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java
+++ b/Mage.Common/src/mage/interfaces/callback/CallbackClientDaemon.java
@@ -86,6 +86,7 @@ public class CallbackClientDaemon extends Thread {
 			}
 		} catch(Exception ex) {
 			logger.fatal("CallbackClientDaemon error ", ex);
+			stopDaemon();
 		}
 	}
 	
diff --git a/Mage.Client/src/main/java/mage/client/remote/MageRemoteException.java b/Mage.Common/src/mage/remote/MageRemoteException.java
similarity index 98%
rename from Mage.Client/src/main/java/mage/client/remote/MageRemoteException.java
rename to Mage.Common/src/mage/remote/MageRemoteException.java
index 006252fd76..4f775473e0 100644
--- a/Mage.Client/src/main/java/mage/client/remote/MageRemoteException.java
+++ b/Mage.Common/src/mage/remote/MageRemoteException.java
@@ -26,7 +26,7 @@
 * or implied, of BetaSteward_at_googlemail.com.
 */
 
-package mage.client.remote;
+package mage.remote;
 
 /**
  *
diff --git a/Mage.Common/src/mage/remote/RMIClientDaemon.java b/Mage.Common/src/mage/remote/RMIClientDaemon.java
index 9ab08294f8..bf96fe4306 100644
--- a/Mage.Common/src/mage/remote/RMIClientDaemon.java
+++ b/Mage.Common/src/mage/remote/RMIClientDaemon.java
@@ -28,8 +28,6 @@
 
 package mage.remote;
 
-import java.util.concurrent.LinkedBlockingQueue;
-
 /**
  *
  * @author BetaSteward_at_googlemail.com
diff --git a/Mage.Common/src/mage/remote/RemoteMethodCall.java b/Mage.Common/src/mage/remote/RemoteMethodCall.java
index 60cec5e8e8..16537b89d0 100644
--- a/Mage.Common/src/mage/remote/RemoteMethodCall.java
+++ b/Mage.Common/src/mage/remote/RemoteMethodCall.java
@@ -29,6 +29,7 @@ package mage.remote;
 
 import java.rmi.*;
 import mage.MageException;
+import mage.constants.Constants.SessionState;
 import mage.interfaces.Server;
 import org.apache.log4j.Logger;
 
@@ -47,12 +48,16 @@ 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){
+	public RemoteMethodCall(Connection connection, String name, SessionState allowedState){
 		this.connection = connection;
+		this.name = name;
+		this.allowedState = allowedState;
 	}
 
 	@Override
@@ -97,6 +102,10 @@ public abstract class RemoteMethodCall<T> extends AbstractRemoteMethodCall<T> {
 		}
 	}
 
+	public String getName() {
+		return name;
+	}
+
 	protected void remoteExceptionOccured(RemoteException remoteException) {
 		ServerCache.removeServerFromCache(connection);
 	}
@@ -112,4 +121,8 @@ public abstract class RemoteMethodCall<T> extends AbstractRemoteMethodCall<T> {
 	public boolean isException() {
 		return exception;
 	}
+
+	public SessionState getAllowedState() {
+		return allowedState;
+	}
 }
diff --git a/Mage.Client/src/main/java/mage/client/remote/Session.java b/Mage.Common/src/mage/remote/Session.java
similarity index 55%
rename from Mage.Client/src/main/java/mage/client/remote/Session.java
rename to Mage.Common/src/mage/remote/Session.java
index c406d1c6c2..3a5911c7df 100644
--- a/Mage.Client/src/main/java/mage/client/remote/Session.java
+++ b/Mage.Common/src/mage/remote/Session.java
@@ -26,44 +26,31 @@
 * or implied, of BetaSteward_at_googlemail.com.
 */
 
-package mage.client.remote;
+package mage.remote;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
-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.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 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.remote.method.*;
-import mage.client.tournament.TournamentPanel;
 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.remote.Connection;
-import mage.remote.RMIClientDaemon;
-import mage.remote.RemoteMethodCallQueue;
-import mage.remote.ServerCache;
-import mage.remote.ServerUnavailable;
 import mage.utils.MageVersion;
 import mage.view.DraftPickView;
 import mage.view.GameTypeView;
@@ -81,29 +68,19 @@ public class Session {
 	private final static Logger logger = Logger.getLogger(Session.class);
 	private static ScheduledExecutorService sessionExecutor = Executors.newScheduledThreadPool(1);
 
-	public enum SessionState {
-		DISCONNECTED, CONNECTED, CONNECTING, DISCONNECTING, SERVER_UNAVAILABLE;
-	}
-
 	private UUID sessionId;
 	private Client client;
 	private String userName;
-	private MageFrame frame;
 	private ServerState serverState;
 	private SessionState sessionState = SessionState.DISCONNECTED;
-	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 RMIClientDaemon rmiDaemon;
 	private RemoteMethodCallQueue q = new RemoteMethodCallQueue();
 	private ScheduledFuture<?> future;
-	private MageUI ui = new MageUI();
 	private Connection connection;
 
-	public Session(MageFrame frame) {
-		this.frame = frame;
+	public Session(Client client) {
+		this.client = client;
 		rmiDaemon = new RMIClientDaemon(q);
 	}
 	
@@ -141,22 +118,19 @@ public class Session {
 			}
 			Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort());
 			this.userName = connection.getUsername();
-			if (client == null)
-				client = new Client(this, frame);
-			sessionId = registerClient(userName, client.getId(), frame.getVersion());
+			sessionId = registerClient(userName, client.getId(), client.getVersion());
 			callbackDaemon = new CallbackClientDaemon(sessionId, client, connection);
 			serverState = getServerState();
 			future = sessionExecutor.scheduleWithFixedDelay(new ServerPinger(), 5, 5, TimeUnit.SECONDS);
 			logger.info("Connected to RMI server at " + connection.getHost() + ":" + connection.getPort());
-			frame.setStatusText("Connected to " + connection.getHost() + ":" + connection.getPort() + " ");
-			frame.enableButtons();
+			client.connected("Connected to " + connection.getHost() + ":" + connection.getPort() + " ");
 			sessionState = SessionState.CONNECTED;
 			return true;
 		} catch (Exception ex) {
 			logger.fatal("", ex);
 			if (sessionState == SessionState.CONNECTING) {
 				disconnect(false);
-				JOptionPane.showMessageDialog(frame, "Unable to connect to server. "  + ex.getMessage());
+				client.showMessage("Unable to connect to server. "  + ex.getMessage());
 			}
 			sessionState = SessionState.SERVER_UNAVAILABLE;
 		}
@@ -169,16 +143,6 @@ public class Session {
 			return;
 		if (future != null && !future.isDone())
 			future.cancel(true);
-		frame.setStatusText("Not connected");
-		frame.disableButtons();
-		try {
-			for (UUID chatId: chats.keySet()) {
-				leaveChat(chatId);
-			}
-		}
-		catch (Exception ignore) {
-			//swallow all exceptions at this point
-		}
 		try {
 			if (callbackDaemon != null)
 				callbackDaemon.stopDaemon();
@@ -187,58 +151,58 @@ public class Session {
 			logger.fatal("Error disconnecting ...", ex);
 		}
 		ServerCache.removeServerFromCache(connection);
-		frame.hideGames();
-		frame.hideTables();
+		client.disconnected();
 		logger.info("Disconnected ... ");
-		if (!voluntary)
-			JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Server error.  You have been disconnected", "Error", JOptionPane.ERROR_MESSAGE);
+		if (!voluntary) {
+			sessionState = SessionState.SERVER_UNAVAILABLE;
+			client.showError("Server error.  You have been disconnected");
+		}
+		else {
+			sessionState = SessionState.DISCONNECTED;
+		}
 	}
-		
-	public boolean ping() {
-		Ping method = new Ping(connection, sessionId);
+
+	private boolean handleCall(RemoteMethodCall method) {
 		try {
-			q.callMethod(method);
-			return method.getReturnVal();
+			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("ping error", 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 {
 		RegisterClient method = new RegisterClient(connection, userName, clientId, version);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("registerClient error", ex);
-		}
 		return null;
 	}
 
 	private void deregisterClient() throws MageException {
 		DeregisterClient method = new DeregisterClient(connection, sessionId);
-		try {
-			q.callMethod(method);
-		} catch (ServerUnavailable ex) {
-			logger.fatal("server unavailable - ", ex);
-		}
+		handleCall(method);
 	}
 
 	private ServerState getServerState() {
 		GetServerState method = new GetServerState(connection);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetServerState error", ex);
-		}
 		return null;
 	}
 
@@ -271,598 +235,250 @@ public class Session {
 		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() {
 		GetMainRoomId method = new GetMainRoomId(connection);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetMainRoomId error", ex);
-		}
 		return null;
 	}
 
 	public UUID getRoomChatId(UUID roomId) {
 		GetRoomChatId method = new GetRoomChatId(connection, roomId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetRoomChatId error", ex);
-		}
 		return null;
 	}
 
 	public UUID getTableChatId(UUID tableId) {
 		GetTableChatId method = new GetTableChatId(connection, tableId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetTableChatId error", ex);
-		}
 		return null;
 	}
 
 	public UUID getGameChatId(UUID gameId) {
 		GetGameChatId method = new GetGameChatId(connection, gameId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetGameChatId error", ex);
-		}
 		return null;
 	}
 
 	public TableView getTable(UUID roomId, UUID tableId) {
 		GetTable method = new GetTable(connection, roomId, tableId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetTable error", ex);
-		}
 		return null;
 	}
 
 	public boolean watchTable(UUID roomId, UUID tableId) {
 		WatchTable method = new WatchTable(connection, sessionId, roomId, tableId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("WatchTable error", ex);
-		}
 		return false;
 	}
 
 	public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) {
 		JoinTable method = new JoinTable(connection, sessionId, roomId, tableId, playerName, playerType, skill, deckList);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (GameException ex) {
-			handleGameException(ex);
-		} catch (InvalidDeckException ex) {
-			handleInvalidDeckException(ex);
-		} catch (MageException ex) {
-			logger.fatal("JoinTable error", ex);
-		}
 		return false;
 	}
 
 	public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill) {
 		JoinTournamentTable method = new JoinTournamentTable(connection, sessionId, roomId, tableId, playerName, playerType, skill);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (GameException ex) {
-			handleGameException(ex);
-		} catch (MageException ex) {
-			logger.fatal("JoinTournamentTable error", ex);
-		}
 		return false;
 	}
 
 	public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
 		GetTables method = new GetTables(connection, roomId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetTables error", ex);
-		}
 		return null;
 	}
 
 	public Collection<String> getConnectedPlayers(UUID roomId) throws MageRemoteException {
 		GetConnectedPlayers method = new GetConnectedPlayers(connection, roomId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetConnectedPlayers error", ex);
-		}
 		return null;
 	}
 
 	public TournamentView getTournament(UUID tournamentId) throws MageRemoteException {
 		GetTournament method = new GetTournament(connection, tournamentId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetTable error", ex);
-		}
 		return null;
 	}
 
 	public UUID getTournamentChatId(UUID tournamentId) {
 		GetTournamentChatId method = new GetTournamentChatId(connection, tournamentId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("GetTournamentChatId error", ex);
-		}
 		return null;
 	}
 
 	public boolean sendPlayerUUID(UUID gameId, UUID data) {
 		SendPlayerUUID method = new SendPlayerUUID(connection, sessionId, gameId, data);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("SendPlayerUUID error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean sendPlayerBoolean(UUID gameId, boolean data) {
 		SendPlayerBoolean method = new SendPlayerBoolean(connection, sessionId, gameId, data);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("SendPlayerBoolean error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean sendPlayerInteger(UUID gameId, int data) {
 		SendPlayerInteger method = new SendPlayerInteger(connection, sessionId, gameId, data);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("SendPlayerInteger error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean sendPlayerString(UUID gameId, String data) {
 		SendPlayerString method = new SendPlayerString(connection, sessionId, gameId, data);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("SendPlayerString error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public DraftPickView sendCardPick(UUID draftId, UUID cardId) {
 		SendCardPick method = new SendCardPick(connection, sessionId, draftId, cardId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("SendCardPick error", ex);
-		}
 		return null;
 	}
 
-	public boolean joinChat(UUID chatId, ChatPanel chat) {
+	public boolean joinChat(UUID chatId) {
 		JoinChat method = new JoinChat(connection, sessionId, chatId, userName);
-		try {
-			q.callMethod(method);
-			chats.put(chatId, chat);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("JoinChat error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean leaveChat(UUID chatId) {
 		LeaveChat method = new LeaveChat(connection, sessionId, chatId);
-		try {
-			q.callMethod(method);
-			chats.remove(chatId);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("LeaveChat error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean sendChatMessage(UUID chatId, String message) {
 		SendChatMessage method = new SendChatMessage(connection, chatId, message, userName);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("SendChatMessage error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean joinGame(UUID gameId) {
 		JoinGame method = new JoinGame(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("JoinGame error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean joinDraft(UUID draftId) {
 		JoinDraft method = new JoinDraft(connection, sessionId, draftId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("JoinDraft error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean joinTournament(UUID tournamentId) {
 		JoinTournament method = new JoinTournament(connection, sessionId, tournamentId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("JoinTournament error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean watchGame(UUID gameId) {
 		WatchGame method = new WatchGame(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("WatchGame error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean replayGame(UUID gameId) {
 		ReplayGame method = new ReplayGame(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("ReplayGame error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public TableView createTable(UUID roomId, MatchOptions matchOptions) {
 		CreateTable method = new CreateTable(connection, sessionId, roomId, matchOptions);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("CreateTable error", ex);
-		}
 		return null;
 	}
 
 	public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) {
 		CreateTournamentTable method = new CreateTournamentTable(connection, sessionId, roomId, tournamentOptions);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("CreateTournamentTable error", ex);
-		}
 		return null;
 	}
 
 	public boolean isTableOwner(UUID roomId, UUID tableId) {
 		IsTableOwner method = new IsTableOwner(connection, sessionId, roomId, tableId);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("IsTableOwner error", ex);
-		}
 		return false;
 	}
 
 	public boolean removeTable(UUID roomId, UUID tableId) {
 		RemoveTable method = new RemoveTable(connection, sessionId, roomId, tableId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("RemoveTable error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) {
 		SwapSeats method = new SwapSeats(connection, sessionId, roomId, tableId, seatNum1, seatNum2);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("RemoveTable error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean leaveTable(UUID roomId, UUID tableId) {
 		LeaveTable method = new LeaveTable(connection, sessionId, roomId, tableId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("LeaveTable error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean startGame(UUID roomId, UUID tableId) {
 		StartGame method = new StartGame(connection, sessionId, roomId, tableId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("StartGame error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean startTournament(UUID roomId, UUID tableId) {
 		StartTournament method = new StartTournament(connection, sessionId, roomId, tableId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("StartTournament error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId) {
 		StartChallenge method = new StartChallenge(connection, sessionId, roomId, tableId, challengeId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("StartChallenge error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean submitDeck(UUID tableId, DeckCardLists deck) {
 		SubmitDeck method = new SubmitDeck(connection, sessionId, tableId, deck);
-		try {
-			q.callMethod(method);
+		if (handleCall(method))
 			return method.getReturnVal();
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (InvalidDeckException ex) {
-			handleInvalidDeckException(ex);
-		} catch (GameException ex) {
-			handleGameException(ex);
-		} catch (MageException ex) {
-			logger.fatal("SubmitDeck error", ex);
-		}
 		return false;
 	}
 
 	public boolean concedeGame(UUID gameId) {
 		ConcedeGame method = new ConcedeGame(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("ConcedeGame error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean stopWatching(UUID gameId) {
 		StopWatching method = new StopWatching(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("StopWatching error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean startReplay(UUID gameId) {
 		StartReplay method = new StartReplay(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("StartReplay error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean stopReplay(UUID gameId) {
 		StopReplay method = new StopReplay(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("StopReplay error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean nextPlay(UUID gameId) {
 		NextPlay method = new NextPlay(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("NextPlay error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean previousPlay(UUID gameId) {
 		PreviousPlay method = new PreviousPlay(connection, sessionId, gameId);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("PreviousPlay error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
 	public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
 		Cheat method = new Cheat(connection, sessionId, gameId, playerId, deckList);
-		try {
-			q.callMethod(method);
-			return true;
-		} catch (ServerUnavailable ex) {
-			handleServerUnavailable(ex);
-		} catch (MageException ex) {
-			logger.fatal("Cheat error", ex);
-		}
-		return false;
+		return handleCall(method);
 	}
 
-//	private void handleRemoteException(RemoteException ex) {
-//		logger.fatal("Communication error", ex);
-//		disconnect(false);
-//	}
-
-//	private void handleMageException(MageException ex) {
-//		logger.fatal("Server error", ex);
-//		disconnect(false);
-//	}
-
 	private void handleServerUnavailable(ServerUnavailable ex) {
 		logger.fatal("server unavailable - ", ex);
 		disconnect(false);
@@ -870,7 +486,7 @@ public class Session {
 	
 	private void handleGameException(GameException ex) {
 		logger.warn(ex.getMessage());
-		JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
+		client.showError(ex.getMessage());
 	}
 
 	private void handleInvalidDeckException(InvalidDeckException ex) {
@@ -880,17 +496,13 @@ public class Session {
 		for (Entry<String, String> entry: ex.getInvalid().entrySet()) {
 			sbMessage.append(entry.getKey()).append(":").append(entry.getValue()).append("\n");
 		}
-		JOptionPane.showMessageDialog(MageFrame.getDesktop(), sbMessage.toString(), "Invalid Deck", JOptionPane.ERROR_MESSAGE);
+		client.showError(sbMessage.toString());
 	}
 
 	public String getUserName() {
 		return userName;
 	}
 
-	public MageUI getUI() {
-		return ui;
-	}
-
 	class ServerPinger implements Runnable {
 
 		@Override
diff --git a/Mage.Common/src/mage/remote/method/Ack.java b/Mage.Common/src/mage/remote/method/Ack.java
index 4c6cc32cfb..36a581cfa2 100644
--- a/Mage.Common/src/mage/remote/method/Ack.java
+++ b/Mage.Common/src/mage/remote/method/Ack.java
@@ -29,6 +29,7 @@ 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;
@@ -44,7 +45,7 @@ public class Ack extends RemoteMethodCall<Void> {
 	private int messageId;
 
 	public Ack(Connection connection, UUID sessionId, int messageId) {
-		super(connection);
+		super(connection, "Ack", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 		this.messageId = messageId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/Callback.java b/Mage.Common/src/mage/remote/method/Callback.java
index ebb860ad1c..540c777175 100644
--- a/Mage.Common/src/mage/remote/method/Callback.java
+++ b/Mage.Common/src/mage/remote/method/Callback.java
@@ -29,6 +29,7 @@ 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;
@@ -44,7 +45,7 @@ public class Callback extends RemoteMethodCall<ClientCallback> {
 	private UUID sessionId;
 
 	public Callback(Connection connection, UUID sessionId) {
-		super(connection);
+		super(connection, "Callback", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/Cheat.java b/Mage.Common/src/mage/remote/method/Cheat.java
index 008162e9f8..be710c5a8e 100644
--- a/Mage.Common/src/mage/remote/method/Cheat.java
+++ b/Mage.Common/src/mage/remote/method/Cheat.java
@@ -32,6 +32,7 @@ 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;
@@ -48,7 +49,7 @@ public class Cheat extends RemoteMethodCall<Void> {
 	private DeckCardLists deckList;
 
 	public Cheat(Connection connection, UUID sessionId, UUID gameId, UUID playerId, DeckCardLists deckList) {
-		super(connection);
+		super(connection, "Cheat", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 		this.playerId = playerId;
diff --git a/Mage.Common/src/mage/remote/method/ConcedeGame.java b/Mage.Common/src/mage/remote/method/ConcedeGame.java
index 2d7844bc06..1c1733b721 100644
--- a/Mage.Common/src/mage/remote/method/ConcedeGame.java
+++ b/Mage.Common/src/mage/remote/method/ConcedeGame.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class ConcedeGame extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public ConcedeGame(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "ConcedeGame", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/CreateTable.java b/Mage.Common/src/mage/remote/method/CreateTable.java
index 6cafce13a3..138ee5b4f9 100644
--- a/Mage.Common/src/mage/remote/method/CreateTable.java
+++ b/Mage.Common/src/mage/remote/method/CreateTable.java
@@ -30,6 +30,7 @@ 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;
@@ -47,7 +48,7 @@ public class CreateTable extends RemoteMethodCall<TableView> {
 	private MatchOptions matchOptions;
 
 	public CreateTable(Connection connection, UUID sessionId, UUID roomId, MatchOptions matchOptions) {
-		super(connection);
+		super(connection, "CreateTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.sessionId = sessionId;
 		this.matchOptions = matchOptions;
diff --git a/Mage.Common/src/mage/remote/method/CreateTournamentTable.java b/Mage.Common/src/mage/remote/method/CreateTournamentTable.java
index d799e481f9..fde8f6c42d 100644
--- a/Mage.Common/src/mage/remote/method/CreateTournamentTable.java
+++ b/Mage.Common/src/mage/remote/method/CreateTournamentTable.java
@@ -30,6 +30,7 @@ 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;
@@ -47,7 +48,7 @@ public class CreateTournamentTable extends RemoteMethodCall<TableView> {
 	private TournamentOptions tournamentOptions;
 
 	public CreateTournamentTable(Connection connection, UUID sessionId, UUID roomId, TournamentOptions tournamentOptions) {
-		super(connection);
+		super(connection, "CreateTournamentTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.sessionId = sessionId;
 		this.tournamentOptions = tournamentOptions;
diff --git a/Mage.Common/src/mage/remote/method/DeregisterClient.java b/Mage.Common/src/mage/remote/method/DeregisterClient.java
index 183555a9b8..61efe19732 100644
--- a/Mage.Common/src/mage/remote/method/DeregisterClient.java
+++ b/Mage.Common/src/mage/remote/method/DeregisterClient.java
@@ -31,6 +31,7 @@ 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;
@@ -44,7 +45,7 @@ public class DeregisterClient extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public DeregisterClient(Connection connection, UUID sessionId) {
-		super(connection);
+		super(connection, "DeregisterClient", SessionState.DISCONNECTING);
 		this.sessionId = sessionId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java b/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java
index 330bfcb199..5c30eed239 100644
--- a/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java
+++ b/Mage.Common/src/mage/remote/method/GetConnectedPlayers.java
@@ -32,6 +32,7 @@ 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;
@@ -45,7 +46,7 @@ public class GetConnectedPlayers extends RemoteMethodCall<List<String>> {
 	private UUID roomId;
 
 	public GetConnectedPlayers(Connection connection, UUID roomId) {
-		super(connection);
+		super(connection, "GetConnectedPlayers", SessionState.CONNECTED);
 		this.roomId = roomId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetGameChatId.java b/Mage.Common/src/mage/remote/method/GetGameChatId.java
index bd5059897f..503d330417 100644
--- a/Mage.Common/src/mage/remote/method/GetGameChatId.java
+++ b/Mage.Common/src/mage/remote/method/GetGameChatId.java
@@ -31,6 +31,7 @@ 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;
@@ -44,7 +45,7 @@ public class GetGameChatId extends RemoteMethodCall<UUID> {
 	private UUID gameId;
 
 	public GetGameChatId(Connection connection, UUID gameId) {
-		super(connection);
+		super(connection, "GetGameChatId", SessionState.CONNECTED);
 		this.gameId = gameId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetMainRoomId.java b/Mage.Common/src/mage/remote/method/GetMainRoomId.java
index 7dd354aa5a..95d093b769 100644
--- a/Mage.Common/src/mage/remote/method/GetMainRoomId.java
+++ b/Mage.Common/src/mage/remote/method/GetMainRoomId.java
@@ -31,6 +31,7 @@ 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;
@@ -43,7 +44,7 @@ public class GetMainRoomId extends RemoteMethodCall<UUID> {
 
 
 	public GetMainRoomId(Connection connection) {
-		super(connection);
+		super(connection, "GetMainRoomId", SessionState.CONNECTED);
 	}
 
 	@Override
diff --git a/Mage.Common/src/mage/remote/method/GetRoomChatId.java b/Mage.Common/src/mage/remote/method/GetRoomChatId.java
index f7a37e59e5..9edab7073a 100644
--- a/Mage.Common/src/mage/remote/method/GetRoomChatId.java
+++ b/Mage.Common/src/mage/remote/method/GetRoomChatId.java
@@ -31,6 +31,7 @@ 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;
@@ -44,7 +45,7 @@ public class GetRoomChatId extends RemoteMethodCall<UUID> {
 	private UUID roomId;
 
 	public GetRoomChatId(Connection connection, UUID roomId) {
-		super(connection);
+		super(connection, "GetRoomChatId", SessionState.CONNECTED);
 		this.roomId = roomId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetServerState.java b/Mage.Common/src/mage/remote/method/GetServerState.java
index 861e31c843..d1f5099c12 100644
--- a/Mage.Common/src/mage/remote/method/GetServerState.java
+++ b/Mage.Common/src/mage/remote/method/GetServerState.java
@@ -29,6 +29,7 @@ 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;
@@ -41,7 +42,7 @@ import mage.remote.RemoteMethodCall;
 public class GetServerState extends RemoteMethodCall<ServerState> {
 
 	public GetServerState(Connection connection) {
-		super(connection);
+		super(connection, "GetServerState", SessionState.CONNECTING);
 	}
 
 	@Override
diff --git a/Mage.Common/src/mage/remote/method/GetTable.java b/Mage.Common/src/mage/remote/method/GetTable.java
index 215b4ca1db..df9f7e1ccf 100644
--- a/Mage.Common/src/mage/remote/method/GetTable.java
+++ b/Mage.Common/src/mage/remote/method/GetTable.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class GetTable extends RemoteMethodCall<TableView> {
 	private UUID tableId;
 
 	public GetTable(Connection connection, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "GetTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/GetTableChatId.java b/Mage.Common/src/mage/remote/method/GetTableChatId.java
index 83f06a63c7..fe01fe9c21 100644
--- a/Mage.Common/src/mage/remote/method/GetTableChatId.java
+++ b/Mage.Common/src/mage/remote/method/GetTableChatId.java
@@ -31,6 +31,7 @@ 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;
@@ -44,7 +45,7 @@ public class GetTableChatId extends RemoteMethodCall<UUID> {
 	private UUID tableId;
 
 	public GetTableChatId(Connection connection, UUID tableId) {
-		super(connection);
+		super(connection, "GetTableChatId", SessionState.CONNECTED);
 		this.tableId = tableId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetTables.java b/Mage.Common/src/mage/remote/method/GetTables.java
index eaa1074841..8368db37a9 100644
--- a/Mage.Common/src/mage/remote/method/GetTables.java
+++ b/Mage.Common/src/mage/remote/method/GetTables.java
@@ -32,6 +32,7 @@ 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;
@@ -46,7 +47,7 @@ public class GetTables extends RemoteMethodCall<List<TableView>> {
 	private UUID roomId;
 
 	public GetTables(Connection connection, UUID roomId) {
-		super(connection);
+		super(connection, "GetTables", SessionState.CONNECTED);
 		this.roomId = roomId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetTournament.java b/Mage.Common/src/mage/remote/method/GetTournament.java
index 1231b42bcc..7d0431ff4c 100644
--- a/Mage.Common/src/mage/remote/method/GetTournament.java
+++ b/Mage.Common/src/mage/remote/method/GetTournament.java
@@ -30,6 +30,7 @@ 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;
@@ -44,7 +45,7 @@ public class GetTournament extends RemoteMethodCall<TournamentView> {
 	private UUID tournamentId;
 
 	public GetTournament(Connection connection, UUID tournamentId) {
-		super(connection);
+		super(connection, "GetTournament", SessionState.CONNECTED);
 		this.tournamentId = tournamentId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/GetTournamentChatId.java b/Mage.Common/src/mage/remote/method/GetTournamentChatId.java
index b23d0ba821..0708ab5bd0 100644
--- a/Mage.Common/src/mage/remote/method/GetTournamentChatId.java
+++ b/Mage.Common/src/mage/remote/method/GetTournamentChatId.java
@@ -31,6 +31,7 @@ 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;
@@ -44,7 +45,7 @@ public class GetTournamentChatId extends RemoteMethodCall<UUID> {
 	private UUID tournamentId;
 
 	public GetTournamentChatId(Connection connection, UUID tournamentId) {
-		super(connection);
+		super(connection, "GetTournamentChatId", SessionState.CONNECTED);
 		this.tournamentId = tournamentId;
 	}
 
diff --git a/Mage.Common/src/mage/remote/method/IsTableOwner.java b/Mage.Common/src/mage/remote/method/IsTableOwner.java
index a5b497d6ff..22f01c217c 100644
--- a/Mage.Common/src/mage/remote/method/IsTableOwner.java
+++ b/Mage.Common/src/mage/remote/method/IsTableOwner.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class IsTableOwner extends RemoteMethodCall<Boolean> {
 	private UUID sessionId;
 	
 	public IsTableOwner(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "IsTableOwner", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/JoinChat.java b/Mage.Common/src/mage/remote/method/JoinChat.java
index b02fae379f..88ae9b51f9 100644
--- a/Mage.Common/src/mage/remote/method/JoinChat.java
+++ b/Mage.Common/src/mage/remote/method/JoinChat.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class JoinChat extends RemoteMethodCall<Void> {
 	private String userName;
 
 	public JoinChat(Connection connection, UUID sessionId, UUID chatId, String userName) {
-		super(connection);
+		super(connection, "JoinChat", SessionState.CONNECTED);
 		this.chatId = chatId;
 		this.sessionId = sessionId;
 		this.userName = userName;
diff --git a/Mage.Common/src/mage/remote/method/JoinDraft.java b/Mage.Common/src/mage/remote/method/JoinDraft.java
index 7be2e6132b..b995c46866 100644
--- a/Mage.Common/src/mage/remote/method/JoinDraft.java
+++ b/Mage.Common/src/mage/remote/method/JoinDraft.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class JoinDraft extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public JoinDraft(Connection connection, UUID sessionId, UUID draftId) {
-		super(connection);
+		super(connection, "JoinDraft", SessionState.CONNECTED);
 		this.draftId = draftId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/JoinGame.java b/Mage.Common/src/mage/remote/method/JoinGame.java
index c0f472d0c6..5615fe4d2b 100644
--- a/Mage.Common/src/mage/remote/method/JoinGame.java
+++ b/Mage.Common/src/mage/remote/method/JoinGame.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class JoinGame extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public JoinGame(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "JoinGame", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/JoinTable.java b/Mage.Common/src/mage/remote/method/JoinTable.java
index 3bddb2ff99..d3ef91aa15 100644
--- a/Mage.Common/src/mage/remote/method/JoinTable.java
+++ b/Mage.Common/src/mage/remote/method/JoinTable.java
@@ -31,6 +31,7 @@ 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;
@@ -51,7 +52,7 @@ public class JoinTable extends RemoteMethodCall<Boolean> {
 	private DeckCardLists deckList;
 
 	public JoinTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) {
-		super(connection);
+		super(connection, "JoinTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/JoinTournament.java b/Mage.Common/src/mage/remote/method/JoinTournament.java
index aaec71600d..566c600eb2 100644
--- a/Mage.Common/src/mage/remote/method/JoinTournament.java
+++ b/Mage.Common/src/mage/remote/method/JoinTournament.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class JoinTournament extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public JoinTournament(Connection connection, UUID sessionId, UUID tournamentId) {
-		super(connection);
+		super(connection, "JoinTournament", SessionState.CONNECTED);
 		this.tournamentId = tournamentId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/JoinTournamentTable.java b/Mage.Common/src/mage/remote/method/JoinTournamentTable.java
index 56800cbbed..e20994a427 100644
--- a/Mage.Common/src/mage/remote/method/JoinTournamentTable.java
+++ b/Mage.Common/src/mage/remote/method/JoinTournamentTable.java
@@ -31,6 +31,7 @@ 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;
@@ -50,7 +51,7 @@ public class JoinTournamentTable extends RemoteMethodCall<Boolean> {
 	private int skill;
 
 	public JoinTournamentTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId, String playerName, String playerType, int skill) {
-		super(connection);
+		super(connection, "JoinTournamentTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/LeaveChat.java b/Mage.Common/src/mage/remote/method/LeaveChat.java
index 1ea3bc4450..efb0c6aab6 100644
--- a/Mage.Common/src/mage/remote/method/LeaveChat.java
+++ b/Mage.Common/src/mage/remote/method/LeaveChat.java
@@ -30,6 +30,7 @@ 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;
@@ -44,7 +45,7 @@ public class LeaveChat extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public LeaveChat(Connection connection, UUID sessionId, UUID chatId) {
-		super(connection);
+		super(connection, "LeaveChat", SessionState.CONNECTED);
 		this.chatId = chatId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/LeaveTable.java b/Mage.Common/src/mage/remote/method/LeaveTable.java
index 8b9fdbcb34..970e2e9f17 100644
--- a/Mage.Common/src/mage/remote/method/LeaveTable.java
+++ b/Mage.Common/src/mage/remote/method/LeaveTable.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class LeaveTable extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 	
 	public LeaveTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "LeaveTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/NextPlay.java b/Mage.Common/src/mage/remote/method/NextPlay.java
index aef8b388e5..190b1c7bbf 100644
--- a/Mage.Common/src/mage/remote/method/NextPlay.java
+++ b/Mage.Common/src/mage/remote/method/NextPlay.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class NextPlay extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public NextPlay(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "NextPlay", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/Ping.java b/Mage.Common/src/mage/remote/method/Ping.java
index 0f7c093b41..cd76bba65a 100644
--- a/Mage.Common/src/mage/remote/method/Ping.java
+++ b/Mage.Common/src/mage/remote/method/Ping.java
@@ -30,6 +30,7 @@ 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;
@@ -43,7 +44,7 @@ public class Ping extends RemoteMethodCall<Boolean> {
 	private UUID sessionId;
 	
 	public Ping(Connection connection, UUID sessionId) {
-		super(connection);
+		super(connection, "Ping", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 	}
 	
diff --git a/Mage.Common/src/mage/remote/method/PreviousPlay.java b/Mage.Common/src/mage/remote/method/PreviousPlay.java
index e4a611b9c9..ee11ce08c8 100644
--- a/Mage.Common/src/mage/remote/method/PreviousPlay.java
+++ b/Mage.Common/src/mage/remote/method/PreviousPlay.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class PreviousPlay extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public PreviousPlay(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "PreviousPlay", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/RegisterClient.java b/Mage.Common/src/mage/remote/method/RegisterClient.java
index 096090c3bc..9b1591d0c3 100644
--- a/Mage.Common/src/mage/remote/method/RegisterClient.java
+++ b/Mage.Common/src/mage/remote/method/RegisterClient.java
@@ -31,6 +31,7 @@ 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;
@@ -47,7 +48,7 @@ public class RegisterClient extends RemoteMethodCall<UUID> {
 	private MageVersion version;
 
 	public RegisterClient(Connection connection, String userName, UUID clientId, MageVersion version) {
-		super(connection);
+		super(connection, "RegisterClient", SessionState.CONNECTING);
 		this.userName = userName;
 		this.clientId = clientId;
 		this.version = version;
diff --git a/Mage.Common/src/mage/remote/method/RemoveTable.java b/Mage.Common/src/mage/remote/method/RemoveTable.java
index feb58447ba..a43994208a 100644
--- a/Mage.Common/src/mage/remote/method/RemoveTable.java
+++ b/Mage.Common/src/mage/remote/method/RemoveTable.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class RemoveTable extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 	
 	public RemoveTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "RemoveTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/ReplayGame.java b/Mage.Common/src/mage/remote/method/ReplayGame.java
index 773145865a..ce1cd1c7ea 100644
--- a/Mage.Common/src/mage/remote/method/ReplayGame.java
+++ b/Mage.Common/src/mage/remote/method/ReplayGame.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class ReplayGame extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public ReplayGame(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "ReplayGame", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/SendCardPick.java b/Mage.Common/src/mage/remote/method/SendCardPick.java
index 80ec1485e7..d51400957e 100644
--- a/Mage.Common/src/mage/remote/method/SendCardPick.java
+++ b/Mage.Common/src/mage/remote/method/SendCardPick.java
@@ -30,6 +30,7 @@ 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;
@@ -46,7 +47,7 @@ public class SendCardPick extends RemoteMethodCall<DraftPickView> {
 	private UUID cardId;
 
 	public SendCardPick(Connection connection, UUID sessionId, UUID draftId, UUID cardId) {
-		super(connection);
+		super(connection, "SendCardPick", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 		this.draftId = draftId;
 		this.cardId = cardId;
diff --git a/Mage.Common/src/mage/remote/method/SendChatMessage.java b/Mage.Common/src/mage/remote/method/SendChatMessage.java
index f3b7729c43..98de05ebef 100644
--- a/Mage.Common/src/mage/remote/method/SendChatMessage.java
+++ b/Mage.Common/src/mage/remote/method/SendChatMessage.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class SendChatMessage extends RemoteMethodCall<Void> {
 	private String userName;
 
 	public SendChatMessage(Connection connection, UUID chatId, String message, String userName) {
-		super(connection);
+		super(connection, "SendChatMessage", SessionState.CONNECTED);
 		this.chatId = chatId;
 		this.message = message;
 		this.userName = userName;
diff --git a/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java b/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java
index 5b573e64b3..09c84d78a0 100644
--- a/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java
+++ b/Mage.Common/src/mage/remote/method/SendPlayerBoolean.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class SendPlayerBoolean extends RemoteMethodCall<Void> {
 	private Boolean data;
 
 	public SendPlayerBoolean(Connection connection, UUID sessionId, UUID gameId, Boolean data) {
-		super(connection);
+		super(connection, "SendPlayerBoolean", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 		this.gameId = gameId;
 		this.data = data;
diff --git a/Mage.Common/src/mage/remote/method/SendPlayerInteger.java b/Mage.Common/src/mage/remote/method/SendPlayerInteger.java
index 2b1978468a..de42bd71a5 100644
--- a/Mage.Common/src/mage/remote/method/SendPlayerInteger.java
+++ b/Mage.Common/src/mage/remote/method/SendPlayerInteger.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class SendPlayerInteger extends RemoteMethodCall<Void> {
 	private Integer data;
 
 	public SendPlayerInteger(Connection connection, UUID sessionId, UUID gameId, Integer data) {
-		super(connection);
+		super(connection, "SendPlayerInteger", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 		this.gameId = gameId;
 		this.data = data;
diff --git a/Mage.Common/src/mage/remote/method/SendPlayerString.java b/Mage.Common/src/mage/remote/method/SendPlayerString.java
index 04c2d2a595..dc71df20e0 100644
--- a/Mage.Common/src/mage/remote/method/SendPlayerString.java
+++ b/Mage.Common/src/mage/remote/method/SendPlayerString.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class SendPlayerString extends RemoteMethodCall<Void> {
 	private String data;
 
 	public SendPlayerString(Connection connection, UUID sessionId, UUID gameId, String data) {
-		super(connection);
+		super(connection, "SendPlayerString", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 		this.gameId = gameId;
 		this.data = data;
diff --git a/Mage.Common/src/mage/remote/method/SendPlayerUUID.java b/Mage.Common/src/mage/remote/method/SendPlayerUUID.java
index c69bfdc6fb..3f90c32d3e 100644
--- a/Mage.Common/src/mage/remote/method/SendPlayerUUID.java
+++ b/Mage.Common/src/mage/remote/method/SendPlayerUUID.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class SendPlayerUUID extends RemoteMethodCall<Void> {
 	private UUID data;
 
 	public SendPlayerUUID(Connection connection, UUID sessionId, UUID gameId, UUID data) {
-		super(connection);
+		super(connection, "SendPlayerUUID", SessionState.CONNECTED);
 		this.sessionId = sessionId;
 		this.gameId = gameId;
 		this.data = data;
diff --git a/Mage.Common/src/mage/remote/method/StartChallenge.java b/Mage.Common/src/mage/remote/method/StartChallenge.java
index 62fcc3ab51..7fe109bd51 100644
--- a/Mage.Common/src/mage/remote/method/StartChallenge.java
+++ b/Mage.Common/src/mage/remote/method/StartChallenge.java
@@ -30,6 +30,7 @@ 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;
@@ -46,7 +47,7 @@ public class StartChallenge extends RemoteMethodCall<Void> {
 	private UUID challengeId;
 	
 	public StartChallenge(Connection connection, UUID sessionId, UUID roomId, UUID tableId, UUID challengeId) {
-		super(connection);
+		super(connection, "StartChallenge", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/StartGame.java b/Mage.Common/src/mage/remote/method/StartGame.java
index 1c1d07a5ba..b16ca17078 100644
--- a/Mage.Common/src/mage/remote/method/StartGame.java
+++ b/Mage.Common/src/mage/remote/method/StartGame.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class StartGame extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 	
 	public StartGame(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "StartGame", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/StartReplay.java b/Mage.Common/src/mage/remote/method/StartReplay.java
index 5b33a897e6..3dbdb8a0f6 100644
--- a/Mage.Common/src/mage/remote/method/StartReplay.java
+++ b/Mage.Common/src/mage/remote/method/StartReplay.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class StartReplay extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public StartReplay(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "StartReplay", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/StartTournament.java b/Mage.Common/src/mage/remote/method/StartTournament.java
index 1c308ed0ad..ac2011d1ef 100644
--- a/Mage.Common/src/mage/remote/method/StartTournament.java
+++ b/Mage.Common/src/mage/remote/method/StartTournament.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class StartTournament extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 	
 	public StartTournament(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "StartTournament", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/StopReplay.java b/Mage.Common/src/mage/remote/method/StopReplay.java
index 6ee96b80ec..cf6a055eb5 100644
--- a/Mage.Common/src/mage/remote/method/StopReplay.java
+++ b/Mage.Common/src/mage/remote/method/StopReplay.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class StopReplay extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public StopReplay(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "StopReplay", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/StopWatching.java b/Mage.Common/src/mage/remote/method/StopWatching.java
index 569b7f1efd..31a4a6964a 100644
--- a/Mage.Common/src/mage/remote/method/StopWatching.java
+++ b/Mage.Common/src/mage/remote/method/StopWatching.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class StopWatching extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public StopWatching(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "StopWatching", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/SubmitDeck.java b/Mage.Common/src/mage/remote/method/SubmitDeck.java
index d2fc31ab8a..cc6fabb3eb 100644
--- a/Mage.Common/src/mage/remote/method/SubmitDeck.java
+++ b/Mage.Common/src/mage/remote/method/SubmitDeck.java
@@ -31,6 +31,7 @@ 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;
@@ -47,7 +48,7 @@ public class SubmitDeck extends RemoteMethodCall<Boolean> {
 	private DeckCardLists deckList;
 
 	public SubmitDeck(Connection connection, UUID sessionId, UUID tableId, DeckCardLists deckList) {
-		super(connection);
+		super(connection, "SubmitDeck", SessionState.CONNECTED);
 		this.tableId = tableId;
 		this.sessionId = sessionId;
 		this.deckList = deckList;
diff --git a/Mage.Common/src/mage/remote/method/SwapSeats.java b/Mage.Common/src/mage/remote/method/SwapSeats.java
index 47a5e83fc5..56339984c9 100644
--- a/Mage.Common/src/mage/remote/method/SwapSeats.java
+++ b/Mage.Common/src/mage/remote/method/SwapSeats.java
@@ -30,6 +30,7 @@ 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;
@@ -47,7 +48,7 @@ public class SwapSeats extends RemoteMethodCall<Void> {
 	private int seat2;
 	
 	public SwapSeats(Connection connection, UUID sessionId, UUID roomId, UUID tableId, int seat1, int seat2) {
-		super(connection);
+		super(connection, "SwapSeats", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;
diff --git a/Mage.Common/src/mage/remote/method/WatchGame.java b/Mage.Common/src/mage/remote/method/WatchGame.java
index db747b2862..943ef58028 100644
--- a/Mage.Common/src/mage/remote/method/WatchGame.java
+++ b/Mage.Common/src/mage/remote/method/WatchGame.java
@@ -31,6 +31,7 @@ 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;
@@ -45,7 +46,7 @@ public class WatchGame extends RemoteMethodCall<Void> {
 	private UUID sessionId;
 
 	public WatchGame(Connection connection, UUID sessionId, UUID gameId) {
-		super(connection);
+		super(connection, "WatchGame", SessionState.CONNECTED);
 		this.gameId = gameId;
 		this.sessionId = sessionId;
 	}
diff --git a/Mage.Common/src/mage/remote/method/WatchTable.java b/Mage.Common/src/mage/remote/method/WatchTable.java
index 252493c4bd..ab446e5e2d 100644
--- a/Mage.Common/src/mage/remote/method/WatchTable.java
+++ b/Mage.Common/src/mage/remote/method/WatchTable.java
@@ -30,6 +30,7 @@ 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;
@@ -45,7 +46,7 @@ public class WatchTable extends RemoteMethodCall<Boolean> {
 	private UUID sessionId;
 
 	public WatchTable(Connection connection, UUID sessionId, UUID roomId, UUID tableId) {
-		super(connection);
+		super(connection, "WatchTable", SessionState.CONNECTED);
 		this.roomId = roomId;
 		this.tableId = tableId;
 		this.sessionId = sessionId;