moved Session to Mage.Common

This commit is contained in:
BetaSteward 2011-06-15 23:24:03 -04:00
parent bbb9e575eb
commit c4a3a496aa
26 changed files with 268 additions and 202 deletions

View file

@ -71,37 +71,50 @@ 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;
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.game.match.MatchOptions;
import mage.interfaces.MageClient;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import mage.remote.Session;
import mage.utils.MageVersion;
import mage.sets.Sets;
import mage.utils.Connection;
import mage.utils.Connection.ProxyType;
import mage.view.TableView;
import org.apache.log4j.Logger;
/**
* @author BetaSteward_at_googlemail.com
*/
public class MageFrame extends javax.swing.JFrame {
public class MageFrame extends javax.swing.JFrame implements MageClient {
private final static Logger logger = Logger.getLogger(MageFrame.class);
private static Session session;
private ConnectDialog connectDialog;
private static CallbackClient callbackClient;
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title;
private Rectangle titleRectangle;
private final static MageVersion version = new MageVersion(0, 7, 4, "beta");
private UUID clientId;
private static MagePane activeFrame;
private static Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
private static Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
private static Map<UUID, DraftPanel> drafts = new HashMap<UUID, DraftPanel>();
private static Map<UUID, TournamentPanel> tournaments = new HashMap<UUID, TournamentPanel>();
private static MageUI ui = new MageUI();
/**
@ -119,6 +132,7 @@ public class MageFrame extends javax.swing.JFrame {
return prefs;
}
@Override
public MageVersion getVersion() {
return version;
}
@ -156,6 +170,7 @@ 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);
ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
@ -739,7 +754,7 @@ public class MageFrame extends javax.swing.JFrame {
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
if (session.isConnected()) {
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
session.disconnect();
session.disconnect(false);
showMessage("You have disconnected");
}
} else {
@ -754,7 +769,7 @@ public class MageFrame extends javax.swing.JFrame {
}//GEN-LAST:event_btnAboutActionPerformed
public void exitApp() {
session.disconnect();
session.disconnect(false);
Plugins.getInstance().shutdown();
dispose();
System.exit(0);
@ -873,10 +888,40 @@ public class MageFrame extends javax.swing.JFrame {
return ui;
}
public static ChatPanel getChat(UUID chatId) {
return chats.get(chatId);
}
public static void addChat(UUID chatId, ChatPanel chatPanel) {
chats.put(chatId, chatPanel);
}
public static GamePanel getGame(UUID gameId) {
return games.get(gameId);
}
public static void addGame(UUID gameId, GamePanel gamePanel) {
games.put(gameId, gamePanel);
}
public static DraftPanel getDraft(UUID draftId) {
return drafts.get(draftId);
}
public static void addDraft(UUID draftId, DraftPanel draftPanel) {
drafts.put(draftId, draftPanel);
}
public static void addTournament(UUID tournamentId, TournamentPanel tournament) {
tournaments.put(tournamentId, tournament);
}
@Override
public UUID getId() {
return clientId;
}
@Override
public void connected(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
setStatusText(message);
@ -893,6 +938,7 @@ public class MageFrame extends javax.swing.JFrame {
}
}
@Override
public void disconnected() {
if (SwingUtilities.isEventDispatchThread()) {
setStatusText("Not connected");
@ -913,6 +959,7 @@ public class MageFrame extends javax.swing.JFrame {
}
}
@Override
public void showMessage(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
JOptionPane.showMessageDialog(desktopPane, message);
@ -927,6 +974,7 @@ public class MageFrame extends javax.swing.JFrame {
}
}
@Override
public void showError(final String message) {
if (SwingUtilities.isEventDispatchThread()) {
JOptionPane.showMessageDialog(desktopPane, message, "Error", JOptionPane.ERROR_MESSAGE);
@ -940,6 +988,11 @@ public class MageFrame extends javax.swing.JFrame {
});
}
}
@Override
public void processCallback(ClientCallback callback) {
callbackClient.processCallback(callback);
}
}

View file

@ -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 = MageFrame.getSession().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 : MageFrame.getSession().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();

View file

@ -40,7 +40,7 @@ import java.util.*;
import java.util.List;
import mage.client.MageFrame;
import mage.client.components.ColorPane;
import mage.client.remote.Session;
import mage.remote.Session;
import mage.view.ChatMessage.MessageColor;
import javax.swing.border.EmptyBorder;
@ -130,7 +130,9 @@ 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() {

View file

@ -50,8 +50,8 @@ import javax.swing.SwingWorker;
import mage.client.MageFrame;
import mage.client.util.Config;
import mage.utils.Connection;
import mage.utils.Connection.ProxyType;
import mage.remote.Connection;
import mage.remote.Connection.ProxyType;
import org.apache.log4j.Logger;

View file

@ -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;

View file

@ -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;

View file

@ -42,7 +42,7 @@ import java.util.concurrent.ExecutionException;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import mage.client.components.MageComponents;
import mage.client.remote.Session;
import mage.remote.Session;
import mage.view.SeatView;
import mage.view.TableView;
import org.apache.log4j.Logger;

View file

@ -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();
}

View file

@ -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;

View file

@ -46,7 +46,7 @@ import javax.swing.*;
import mage.client.MageFrame;
import mage.client.components.MageTextArea;
import mage.client.components.arcane.GlowText;
import mage.client.remote.Session;
import mage.remote.Session;
import org.apache.log4j.Logger;

View file

@ -58,7 +58,7 @@ import mage.client.dialog.PickNumberDialog;
import mage.client.dialog.ShowCardsDialog;
import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.impl.Plugins;
import mage.client.remote.Session;
import mage.remote.Session;
import mage.client.util.Config;
import mage.client.util.GameManager;
import mage.client.util.PhaseManager;
@ -161,7 +161,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameId = gameId;
this.playerId = playerId;
session = MageFrame.getSession();
session.addGame(gameId, this);
MageFrame.addGame(gameId, this);
this.feedbackPanel.init(gameId);
this.feedbackPanel.clear();
this.abilityPicker.init(session, gameId);
@ -178,7 +178,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameId = gameId;
this.playerId = null;
session = MageFrame.getSession();
session.addGame(gameId, this);
MageFrame.addGame(gameId, this);
this.feedbackPanel.init(gameId);
this.feedbackPanel.clear();
this.btnConcede.setVisible(false);
@ -194,7 +194,7 @@ public class GamePanel extends javax.swing.JPanel {
this.gameId = gameId;
this.playerId = null;
session = MageFrame.getSession();
session.addGame(gameId, this);
MageFrame.addGame(gameId, this);
this.feedbackPanel.clear();
this.btnConcede.setVisible(false);
this.btnStopWatching.setVisible(false);

View file

@ -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;

View file

@ -40,7 +40,7 @@ import mage.client.components.HoverButton;
import mage.client.components.MageRoundPane;
import mage.client.components.arcane.ManaSymbols;
import mage.client.dialog.ShowCardsDialog;
import mage.client.remote.Session;
import mage.remote.Session;
import mage.client.util.Command;
import mage.client.util.Config;
import mage.client.util.ImageHelper;

View file

@ -18,7 +18,7 @@ import mage.client.cards.BigCard;
import mage.client.components.MageComponents;
import mage.client.game.PlayAreaPanel;
import mage.client.plugins.impl.Plugins;
import mage.client.remote.Session;
import mage.remote.Session;
import mage.client.util.DefaultActionCallback;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
@ -82,13 +82,13 @@ public class MageActionCallback implements ActionCallback {
for (UUID uuid : targets) {
//System.out.println("Getting play area panel for uuid: " + uuid);
PlayAreaPanel p = 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();
@ -105,7 +105,7 @@ public class MageActionCallback implements ActionCallback {
Point me = new Point(data.locationOnScreen);
me.translate(-parentPoint.x, -parentPoint.y);
UUID uuid = data.card.getParentId();
for (PlayAreaPanel pa : 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();

View file

@ -28,9 +28,7 @@
package mage.client.remote;
import java.rmi.RemoteException;
import java.util.UUID;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
@ -40,8 +38,10 @@ import mage.client.draft.DraftPanel;
import mage.client.game.GamePanel;
import mage.client.plugins.impl.Plugins;
import mage.client.util.GameManager;
import mage.client.util.object.SaveObjectUtil;
import mage.interfaces.callback.CallbackClient;
import mage.interfaces.callback.ClientCallback;
import mage.utils.CompressUtil;
import mage.view.AbilityPickerView;
import mage.view.ChatMessage;
import mage.view.DraftClientMessage;
@ -55,26 +55,26 @@ import org.apache.log4j.Logger;
*
* @author BetaSteward_at_googlemail.com
*/
public class 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;
}
@Override
public synchronized void processCallback(final ClientCallback callback) {
logger.info(callback.getMessageId() + " - " + callback.getMethod());
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
callback.setData(CompressUtil.decompress(callback.getData()));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@ -101,7 +101,7 @@ public class 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) {
if (message.isUserMessage() && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
@ -111,31 +111,31 @@ public class Client implements CallbackClient {
}
}
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());
session.ack("gameInit");
}
}
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();
@ -143,53 +143,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());
}
@ -197,7 +197,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());
}
@ -214,18 +214,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());
}
@ -238,10 +238,10 @@ public class Client implements CallbackClient {
}
}
else if (callback.getMethod().equals("draftInit")) {
session.ack("draftInit");
}
else if (callback.getMethod().equals("tournamentInit")) {
session.ack("tournamentInit");
}
messageId = callback.getMessageId();
}
@ -252,7 +252,7 @@ public class Client implements CallbackClient {
});
}
public UUID getId() throws RemoteException {
public UUID getId() {
return clientId;
}
@ -320,9 +320,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();
frame.disableButtons();
frame.showError("Error: " + ex.getMessage());
}
}

View file

@ -1,37 +0,0 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.remote;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class MageRemoteException extends Exception {
}

View file

@ -1,851 +0,0 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.remote;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.swing.JOptionPane;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.components.MageUI;
import mage.client.draft.DraftPanel;
import mage.client.game.GamePanel;
import mage.client.tournament.TournamentPanel;
import mage.client.util.Config;
import mage.game.GameException;
import mage.MageException;
import mage.game.match.MatchOptions;
import mage.game.tournament.TournamentOptions;
import mage.interfaces.Server;
import mage.interfaces.ServerState;
import mage.interfaces.callback.CallbackClientDaemon;
import mage.utils.Connection;
import mage.view.DraftPickView;
import mage.view.GameTypeView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import mage.view.TournamentView;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Session {
private final static Logger logger = Logger.getLogger(Session.class);
private static ScheduledExecutorService sessionExecutor = Executors.newScheduledThreadPool(1);
private UUID sessionId;
private Server server;
private Client client;
private String userName;
private MageFrame frame;
private ServerState serverState;
private Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
private Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
private Map<UUID, DraftPanel> drafts = new HashMap<UUID, DraftPanel>();
private Map<UUID, TournamentPanel> tournaments = new HashMap<UUID, TournamentPanel>();
private CallbackClientDaemon callbackDaemon;
private ScheduledFuture<?> future;
private MageUI ui = new MageUI();
/**
* For locking session object.
* Read-write locking is used for better performance, as in most cases session object won't be changed so
* there shouldn't be any penalty for synchronization.
*
* @author nantuko
*/
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
public Session(MageFrame frame) {
this.frame = frame;
}
public boolean connect(Connection connection) {
if (isConnected()) {
disconnect();
}
try {
System.setSecurityManager(null);
System.setProperty("http.nonProxyHosts", "code.google.com");
System.setProperty("socksNonProxyHosts", "code.google.com");
// clear previous values
System.clearProperty("socksProxyHost");
System.clearProperty("socksProxyPort");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
switch (connection.getProxyType()) {
case SOCKS:
System.setProperty("socksProxyHost", connection.getProxyHost());
System.setProperty("socksProxyPort", Integer.toString(connection.getProxyPort()));
break;
case HTTP:
System.setProperty("http.proxyHost", connection.getProxyHost());
System.setProperty("http.proxyPort", Integer.toString(connection.getProxyPort()));
Authenticator.setDefault(new MageAuthenticator(connection.getProxyUsername(), connection.getProxyPassword()));
break;
}
Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort());
this.server = (Server) reg.lookup(Config.remoteServer);
this.userName = connection.getUsername();
if (client == null)
client = new Client(this, frame);
sessionId = server.registerClient(userName, client.getId(), frame.getVersion());
callbackDaemon = new CallbackClientDaemon(sessionId, client, server);
serverState = server.getServerState();
future = sessionExecutor.scheduleWithFixedDelay(new ServerPinger(), 5, 5, TimeUnit.SECONDS);
logger.info("Connected to RMI server at " + connection.getHost() + ":" + connection.getPort());
frame.setStatusText("Connected to " + connection.getHost() + ":" + connection.getPort() + " ");
frame.enableButtons();
return true;
} catch (MageException ex) {
logger.fatal("", ex);
disconnect();
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
} catch (RemoteException ex) {
logger.fatal("Unable to connect to server - ", ex);
disconnect();
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
} catch (NotBoundException ex) {
logger.fatal("Unable to connect to server - ", ex);
}
return false;
}
public void disconnect() {
if (isConnected()) {
try {
for (UUID chatId: chats.keySet()) {
server.leaveChat(chatId, sessionId);
}
}
catch (Exception ex) {
//swallow all exceptions at this point
}
try {
//TODO: stop daemon
if (server != null)
server.deregisterClient(sessionId);
} catch (RemoteException ex) {
logger.fatal("Error disconnecting ...", ex);
} catch (MageException ex) {
logger.fatal("Error disconnecting ...", ex);
}
removeServer();
}
}
private void removeServer() {
if (future != null && !future.isDone())
future.cancel(true);
lock.writeLock().lock();
try {
server = null;
} finally {
lock.writeLock().unlock();
}
frame.hideGames();
frame.hideTables();
frame.setStatusText("Not connected");
frame.disableButtons();
logger.info("Disconnected ... ");
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Disconnected.", "Disconnected", JOptionPane.INFORMATION_MESSAGE);
}
public void ack(String message) {
try {
server.ack(message, sessionId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
}
public boolean ping() {
try {
return server.ping(sessionId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean isConnected() {
return server != null;
}
public String[] getPlayerTypes() {
return serverState.getPlayerTypes();
}
public List<GameTypeView> getGameTypes() {
return serverState.getGameTypes();
}
public String[] getDeckTypes() {
return serverState.getDeckTypes();
}
public List<TournamentTypeView> getTournamentTypes() {
return serverState.getTournamentTypes();
}
public boolean isTestMode() {
if (serverState != null)
return serverState.isTestMode();
return false;
}
public ChatPanel getChat(UUID chatId) {
return chats.get(chatId);
}
public GamePanel getGame(UUID gameId) {
return games.get(gameId);
}
public void addGame(UUID gameId, GamePanel gamePanel) {
games.put(gameId, gamePanel);
}
public DraftPanel getDraft(UUID draftId) {
return drafts.get(draftId);
}
public void addDraft(UUID draftId, DraftPanel draftPanel) {
drafts.put(draftId, draftPanel);
}
public void addTournament(UUID tournamentId, TournamentPanel tournament) {
tournaments.put(tournamentId, tournament);
}
public UUID getMainRoomId() {
try {
return server.getMainRoomId();
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public UUID getRoomChatId(UUID roomId) {
try {
return server.getRoomChatId(roomId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public UUID getTableChatId(UUID tableId) {
try {
return server.getTableChatId(tableId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public UUID getGameChatId(UUID gameId) {
try {
return server.getGameChatId(gameId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public TableView getTable(UUID roomId, UUID tableId) {
try {
return server.getTable(roomId, tableId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public boolean watchTable(UUID roomId, UUID tableId) {
try {
server.watchTable(sessionId, roomId, tableId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) {
try {
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (GameException ex) {
handleGameException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill) {
try {
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (GameException ex) {
handleGameException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
lock.readLock().lock();
try {
if (server == null) return null;
return server.getTables(roomId);
} catch (RemoteException ex) {
handleRemoteException(ex);
throw new MageRemoteException();
} catch (MageException ex) {
handleMageException(ex);
throw new MageRemoteException();
} finally {
lock.readLock().unlock();
}
}
public Collection<String> getConnectedPlayers(UUID roomId) throws MageRemoteException {
lock.readLock().lock();
try {
return server.getConnectedPlayers(roomId);
} catch (RemoteException ex) {
handleRemoteException(ex);
throw new MageRemoteException();
} catch (MageException ex) {
handleMageException(ex);
throw new MageRemoteException();
} finally {
lock.readLock().unlock();
}
}
public TournamentView getTournament(UUID tournamentId) throws MageRemoteException {
try {
return server.getTournament(tournamentId);
} catch (RemoteException ex) {
handleRemoteException(ex);
throw new MageRemoteException();
} catch (MageException ex) {
handleMageException(ex);
throw new MageRemoteException();
}
}
public UUID getTournamentChatId(UUID tournamentId) {
try {
return server.getTournamentChatId(tournamentId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public boolean sendPlayerUUID(UUID gameId, UUID data) {
try {
server.sendPlayerUUID(gameId, sessionId, data);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean sendPlayerBoolean(UUID gameId, boolean data) {
try {
server.sendPlayerBoolean(gameId, sessionId, data);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean sendPlayerInteger(UUID gameId, int data) {
try {
server.sendPlayerInteger(gameId, sessionId, data);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean sendPlayerString(UUID gameId, String data) {
try {
server.sendPlayerString(gameId, sessionId, data);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public DraftPickView sendCardPick(UUID draftId, UUID cardId) {
try {
return server.sendCardPick(draftId, sessionId, cardId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public boolean joinChat(UUID chatId, ChatPanel chat) {
try {
server.joinChat(chatId, sessionId, userName);
chats.put(chatId, chat);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean leaveChat(UUID chatId) {
lock.readLock().lock();
try {
if (server == null) return false;
server.leaveChat(chatId, sessionId);
chats.remove(chatId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
} finally {
lock.readLock().unlock();
}
return false;
}
public boolean sendChatMessage(UUID chatId, String message) {
lock.readLock().lock();
try {
if (server == null) return false;
server.sendChatMessage(chatId, userName, message);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
} finally {
lock.readLock().unlock();
}
return false;
}
public boolean joinGame(UUID gameId) {
try {
server.joinGame(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean joinDraft(UUID draftId) {
try {
server.joinDraft(draftId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean joinTournament(UUID tournamentId) {
try {
server.joinTournament(tournamentId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean watchGame(UUID gameId) {
try {
server.watchGame(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean replayGame(UUID gameId) {
try {
server.replayGame(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public TableView createTable(UUID roomId, MatchOptions matchOptions) {
try {
return server.createTable(sessionId, roomId, matchOptions);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public TableView createTournamentTable(UUID roomId, TournamentOptions tournamentOptions) {
try {
return server.createTournamentTable(sessionId, roomId, tournamentOptions);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public boolean isTableOwner(UUID roomId, UUID tableId) {
try {
return server.isTableOwner(sessionId, roomId, tableId);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean removeTable(UUID roomId, UUID tableId) {
try {
server.removeTable(sessionId, roomId, tableId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean swapSeats(UUID roomId, UUID tableId, int seatNum1, int seatNum2) {
try {
server.swapSeats(sessionId, roomId, tableId, seatNum1, seatNum2);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean leaveTable(UUID roomId, UUID tableId) {
try {
server.leaveTable(sessionId, roomId, tableId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean startGame(UUID roomId, UUID tableId) {
try {
server.startMatch(sessionId, roomId, tableId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean startTournament(UUID roomId, UUID tableId) {
try {
server.startTournament(sessionId, roomId, tableId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId) {
try {
server.startChallenge(sessionId, roomId, tableId, challengeId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
try {
return server.submitDeck(sessionId, tableId, deck);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (GameException ex) {
handleGameException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean concedeGame(UUID gameId) {
try {
server.concedeGame(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean stopWatching(UUID gameId) {
try {
server.stopWatching(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean startReplay(UUID gameId) {
try {
server.startReplay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean stopReplay(UUID gameId) {
try {
server.stopReplay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean nextPlay(UUID gameId) {
try {
server.nextPlay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean previousPlay(UUID gameId) {
try {
server.previousPlay(gameId, sessionId);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
public boolean cheat(UUID gameId, UUID playerId, DeckCardLists deckList) {
try {
server.cheat(gameId, sessionId, playerId, deckList);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return false;
}
private void handleRemoteException(RemoteException ex) {
logger.fatal("Communication error", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Critical server error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
disconnect();
}
private void handleMageException(MageException ex) {
logger.fatal("Server error", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Critical server error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
disconnect();
}
private void handleGameException(GameException ex) {
logger.warn(ex.getMessage());
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
public String getUserName() {
return userName;
}
public MageUI getUI() {
return ui;
}
public Server getServerRef() {
return server;
}
class ServerPinger implements Runnable {
private int missed = 0;
@Override
public void run() {
if (!ping()) {
missed++;
if (missed > 10) {
logger.info("Connection to server timed out");
removeServer();
}
}
else {
missed = 0;
}
}
}
}
class MageAuthenticator extends Authenticator {
private String username;
private String password;
public MageAuthenticator(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public PasswordAuthentication getPasswordAuthentication () {
return new PasswordAuthentication (username, password.toCharArray());
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
/**
*

View file

@ -36,20 +36,15 @@ package mage.client.tournament;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
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.Session;
import mage.client.util.ButtonColumn;
import mage.view.RoundView;
import mage.view.TournamentGameView;
@ -104,7 +99,7 @@ public class TournamentPanel extends javax.swing.JPanel {
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);

View file

@ -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;