mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
moved Session to Mage.Common
This commit is contained in:
parent
bbb9e575eb
commit
c4a3a496aa
26 changed files with 268 additions and 202 deletions
|
|
@ -71,30 +71,39 @@ import java.util.List;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.event.PopupMenuEvent;
|
import javax.swing.event.PopupMenuEvent;
|
||||||
import javax.swing.event.PopupMenuListener;
|
import javax.swing.event.PopupMenuListener;
|
||||||
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.components.MageUI;
|
import mage.client.components.MageUI;
|
||||||
import mage.client.deckeditor.DeckEditorPane;
|
import mage.client.deckeditor.DeckEditorPane;
|
||||||
import mage.client.draft.DraftPane;
|
import mage.client.draft.DraftPane;
|
||||||
|
import mage.client.draft.DraftPanel;
|
||||||
import mage.client.game.GamePane;
|
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.table.TablesPane;
|
||||||
import mage.client.tournament.TournamentPane;
|
import mage.client.tournament.TournamentPane;
|
||||||
|
import mage.client.tournament.TournamentPanel;
|
||||||
import mage.game.match.MatchOptions;
|
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.utils.MageVersion;
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
import mage.utils.Connection;
|
|
||||||
import mage.utils.Connection.ProxyType;
|
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @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 final static Logger logger = Logger.getLogger(MageFrame.class);
|
||||||
|
|
||||||
private static Session session;
|
private static Session session;
|
||||||
private ConnectDialog connectDialog;
|
private ConnectDialog connectDialog;
|
||||||
|
private static CallbackClient callbackClient;
|
||||||
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
|
||||||
private JLabel title;
|
private JLabel title;
|
||||||
private Rectangle titleRectangle;
|
private Rectangle titleRectangle;
|
||||||
|
|
@ -102,6 +111,10 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
private UUID clientId;
|
private UUID clientId;
|
||||||
private static MagePane activeFrame;
|
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();
|
private static MageUI ui = new MageUI();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -119,6 +132,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
return prefs;
|
return prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MageVersion getVersion() {
|
public MageVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
@ -156,6 +170,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||||
|
|
||||||
session = new Session(this);
|
session = new Session(this);
|
||||||
|
callbackClient = new CallbackClientImpl(this);
|
||||||
connectDialog = new ConnectDialog();
|
connectDialog = new ConnectDialog();
|
||||||
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER);
|
||||||
ui.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
|
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
|
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||||
if (session.isConnected()) {
|
if (session.isConnected()) {
|
||||||
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
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");
|
showMessage("You have disconnected");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -754,7 +769,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
}//GEN-LAST:event_btnAboutActionPerformed
|
}//GEN-LAST:event_btnAboutActionPerformed
|
||||||
|
|
||||||
public void exitApp() {
|
public void exitApp() {
|
||||||
session.disconnect();
|
session.disconnect(false);
|
||||||
Plugins.getInstance().shutdown();
|
Plugins.getInstance().shutdown();
|
||||||
dispose();
|
dispose();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
@ -873,10 +888,40 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
return ui;
|
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() {
|
public UUID getId() {
|
||||||
return clientId;
|
return clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void connected(final String message) {
|
public void connected(final String message) {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
setStatusText(message);
|
setStatusText(message);
|
||||||
|
|
@ -893,6 +938,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected() {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
setStatusText("Not connected");
|
setStatusText("Not connected");
|
||||||
|
|
@ -913,6 +959,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showMessage(final String message) {
|
public void showMessage(final String message) {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
JOptionPane.showMessageDialog(desktopPane, message);
|
JOptionPane.showMessageDialog(desktopPane, message);
|
||||||
|
|
@ -927,6 +974,7 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void showError(final String message) {
|
public void showError(final String message) {
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
if (SwingUtilities.isEventDispatchThread()) {
|
||||||
JOptionPane.showMessageDialog(desktopPane, message, "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(desktopPane, message, "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
@ -941,6 +989,11 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processCallback(ClientCallback callback) {
|
||||||
|
callbackClient.processCallback(callback);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
class MagePaneMenuItem extends JCheckBoxMenuItem {
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ import mage.cards.MagePermanent;
|
||||||
import mage.cards.TextPopup;
|
import mage.cards.TextPopup;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.game.PlayAreaPanel;
|
import mage.client.game.PlayAreaPanel;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.DefaultActionCallback;
|
import mage.client.util.DefaultActionCallback;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
|
|
@ -382,13 +382,13 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
||||||
List<UUID> targets = card.getTargets();
|
List<UUID> targets = card.getTargets();
|
||||||
if (targets != null) {
|
if (targets != null) {
|
||||||
for (UUID uuid : targets) {
|
for (UUID uuid : targets) {
|
||||||
PlayAreaPanel p = MageFrame.getSession().getGame(gameId).getPlayers().get(uuid);
|
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(uuid);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Point target = p.getLocationOnScreen();
|
Point target = p.getLocationOnScreen();
|
||||||
Point me = this.getLocationOnScreen();
|
Point me = this.getLocationOnScreen();
|
||||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red);
|
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red);
|
||||||
} else {
|
} 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);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point target = permanent.getLocationOnScreen();
|
Point target = permanent.getLocationOnScreen();
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.components.ColorPane;
|
import mage.client.components.ColorPane;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
@ -130,7 +130,9 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
public void connect(UUID chatId) {
|
public void connect(UUID chatId) {
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
this.chatId = chatId;
|
this.chatId = chatId;
|
||||||
session.joinChat(chatId, this);
|
if (session.joinChat(chatId)) {
|
||||||
|
MageFrame.addChat(chatId, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ import javax.swing.SwingWorker;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.utils.Connection;
|
import mage.remote.Connection;
|
||||||
import mage.utils.Connection.ProxyType;
|
import mage.remote.Connection.ProxyType;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ package mage.client.dialog;
|
||||||
import mage.client.*;
|
import mage.client.*;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import javax.swing.SpinnerNumberModel;
|
||||||
import mage.Constants.MultiplayerAttackOption;
|
import mage.Constants.MultiplayerAttackOption;
|
||||||
import mage.Constants.RangeOfInfluence;
|
import mage.Constants.RangeOfInfluence;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.table.TablePlayerPanel;
|
import mage.client.table.TablePlayerPanel;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.SeatView;
|
import mage.view.SeatView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import java.util.UUID;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.constants.Constants.SortBy;
|
import mage.client.constants.Constants.SortBy;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
|
|
@ -81,7 +81,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
||||||
public synchronized void showDraft(UUID draftId) {
|
public synchronized void showDraft(UUID draftId) {
|
||||||
this.draftId = draftId;
|
this.draftId = draftId;
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
session.addDraft(draftId, this);
|
MageFrame.addDraft(draftId, this);
|
||||||
if (!session.joinDraft(draftId))
|
if (!session.joinDraft(draftId))
|
||||||
hideDraft();
|
hideDraft();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import javax.swing.JPopupMenu;
|
||||||
import javax.swing.event.PopupMenuEvent;
|
import javax.swing.event.PopupMenuEvent;
|
||||||
import javax.swing.event.PopupMenuListener;
|
import javax.swing.event.PopupMenuListener;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import javax.swing.*;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.components.MageTextArea;
|
import mage.client.components.MageTextArea;
|
||||||
import mage.client.components.arcane.GlowText;
|
import mage.client.components.arcane.GlowText;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ import mage.client.dialog.PickNumberDialog;
|
||||||
import mage.client.dialog.ShowCardsDialog;
|
import mage.client.dialog.ShowCardsDialog;
|
||||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.GameManager;
|
import mage.client.util.GameManager;
|
||||||
import mage.client.util.PhaseManager;
|
import mage.client.util.PhaseManager;
|
||||||
|
|
@ -161,7 +161,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
session.addGame(gameId, this);
|
MageFrame.addGame(gameId, this);
|
||||||
this.feedbackPanel.init(gameId);
|
this.feedbackPanel.init(gameId);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
this.abilityPicker.init(session, gameId);
|
this.abilityPicker.init(session, gameId);
|
||||||
|
|
@ -178,7 +178,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = null;
|
this.playerId = null;
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
session.addGame(gameId, this);
|
MageFrame.addGame(gameId, this);
|
||||||
this.feedbackPanel.init(gameId);
|
this.feedbackPanel.init(gameId);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
this.btnConcede.setVisible(false);
|
this.btnConcede.setVisible(false);
|
||||||
|
|
@ -194,7 +194,7 @@ public class GamePanel extends javax.swing.JPanel {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
this.playerId = null;
|
this.playerId = null;
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
session.addGame(gameId, this);
|
MageFrame.addGame(gameId, this);
|
||||||
this.feedbackPanel.clear();
|
this.feedbackPanel.clear();
|
||||||
this.btnConcede.setVisible(false);
|
this.btnConcede.setVisible(false);
|
||||||
this.btnStopWatching.setVisible(false);
|
this.btnStopWatching.setVisible(false);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import java.util.UUID;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.dialog.ShowCardsDialog;
|
import mage.client.dialog.ShowCardsDialog;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.view.PlayerView;
|
import mage.view.PlayerView;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import mage.client.components.HoverButton;
|
||||||
import mage.client.components.MageRoundPane;
|
import mage.client.components.MageRoundPane;
|
||||||
import mage.client.components.arcane.ManaSymbols;
|
import mage.client.components.arcane.ManaSymbols;
|
||||||
import mage.client.dialog.ShowCardsDialog;
|
import mage.client.dialog.ShowCardsDialog;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.Command;
|
import mage.client.util.Command;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import mage.client.cards.BigCard;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.client.game.PlayAreaPanel;
|
import mage.client.game.PlayAreaPanel;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.DefaultActionCallback;
|
import mage.client.util.DefaultActionCallback;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
import mage.client.util.gui.ArrowBuilder;
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
|
|
@ -82,13 +82,13 @@ public class MageActionCallback implements ActionCallback {
|
||||||
for (UUID uuid : targets) {
|
for (UUID uuid : targets) {
|
||||||
//System.out.println("Getting play area panel for uuid: " + uuid);
|
//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) {
|
if (p != null) {
|
||||||
Point target = p.getLocationOnScreen();
|
Point target = p.getLocationOnScreen();
|
||||||
target.translate(-parentPoint.x, -parentPoint.y);
|
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);
|
ArrowBuilder.addArrow((int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 40, (int) target.getY() - 40, Color.red);
|
||||||
} else {
|
} 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);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point target = permanent.getLocationOnScreen();
|
Point target = permanent.getLocationOnScreen();
|
||||||
|
|
@ -105,7 +105,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
Point me = new Point(data.locationOnScreen);
|
Point me = new Point(data.locationOnScreen);
|
||||||
me.translate(-parentPoint.x, -parentPoint.y);
|
me.translate(-parentPoint.x, -parentPoint.y);
|
||||||
UUID uuid = data.card.getParentId();
|
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);
|
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Point source = permanent.getLocationOnScreen();
|
Point source = permanent.getLocationOnScreen();
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,7 @@
|
||||||
|
|
||||||
package mage.client.remote;
|
package mage.client.remote;
|
||||||
|
|
||||||
import java.rmi.RemoteException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
|
@ -40,8 +38,10 @@ import mage.client.draft.DraftPanel;
|
||||||
import mage.client.game.GamePanel;
|
import mage.client.game.GamePanel;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.GameManager;
|
import mage.client.util.GameManager;
|
||||||
|
import mage.client.util.object.SaveObjectUtil;
|
||||||
import mage.interfaces.callback.CallbackClient;
|
import mage.interfaces.callback.CallbackClient;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
|
import mage.utils.CompressUtil;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.AbilityPickerView;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
import mage.view.DraftClientMessage;
|
import mage.view.DraftClientMessage;
|
||||||
|
|
@ -55,26 +55,26 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @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 UUID clientId;
|
||||||
private MageFrame frame;
|
private MageFrame frame;
|
||||||
private Session session;
|
|
||||||
private int messageId = 0;
|
private int messageId = 0;
|
||||||
|
|
||||||
public Client(Session session, MageFrame frame) {
|
public CallbackClientImpl(MageFrame frame) {
|
||||||
|
|
||||||
this.clientId = UUID.randomUUID();
|
this.clientId = UUID.randomUUID();
|
||||||
this.frame = frame;
|
this.frame = frame;
|
||||||
this.session = session;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void processCallback(final ClientCallback callback) {
|
public synchronized void processCallback(final ClientCallback callback) {
|
||||||
logger.info(callback.getMessageId() + " - " + callback.getMethod());
|
logger.info(callback.getMessageId() + " - " + callback.getMethod());
|
||||||
|
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
||||||
|
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
@ -101,7 +101,7 @@ public class Client implements CallbackClient {
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("chatMessage")) {
|
else if (callback.getMethod().equals("chatMessage")) {
|
||||||
ChatMessage message = (ChatMessage) callback.getData();
|
ChatMessage message = (ChatMessage) callback.getData();
|
||||||
ChatPanel panel = session.getChat(callback.getObjectId());
|
ChatPanel panel = frame.getChat(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
if (message.isUserMessage() && panel.getConnectedChat() != null) {
|
if (message.isUserMessage() && panel.getConnectedChat() != null) {
|
||||||
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
|
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")) {
|
else if (callback.getMethod().equals("replayInit")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.init((GameView) callback.getData());
|
panel.init((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("replayDone")) {
|
else if (callback.getMethod().equals("replayDone")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.modalMessage((String) callback.getData());
|
panel.modalMessage((String) callback.getData());
|
||||||
panel.hideGame();
|
panel.hideGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("replayUpdate")) {
|
else if (callback.getMethod().equals("replayUpdate")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.updateGame((GameView) callback.getData());
|
panel.updateGame((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameInit")) {
|
else if (callback.getMethod().equals("gameInit")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.init((GameView) callback.getData());
|
panel.init((GameView) callback.getData());
|
||||||
session.ack("gameInit");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameOver")) {
|
else if (callback.getMethod().equals("gameOver")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null) {
|
if (panel != null) {
|
||||||
panel.modalMessage((String) callback.getData());
|
panel.modalMessage((String) callback.getData());
|
||||||
panel.hideGame();
|
panel.hideGame();
|
||||||
|
|
@ -143,53 +143,53 @@ public class Client implements CallbackClient {
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameAsk")) {
|
else if (callback.getMethod().equals("gameAsk")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.ask(message.getMessage(), message.getGameView());
|
panel.ask(message.getMessage(), message.getGameView());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameTarget")) {
|
else if (callback.getMethod().equals("gameTarget")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
|
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameSelect")) {
|
else if (callback.getMethod().equals("gameSelect")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.select(message.getMessage(), message.getGameView());
|
panel.select(message.getMessage(), message.getGameView());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameChooseAbility")) {
|
else if (callback.getMethod().equals("gameChooseAbility")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameChoose")) {
|
else if (callback.getMethod().equals("gameChoose")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.getChoice(message.getMessage(), message.getStrings());
|
panel.getChoice(message.getMessage(), message.getStrings());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gamePlayMana")) {
|
else if (callback.getMethod().equals("gamePlayMana")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.playMana(message.getMessage(), message.getGameView());
|
panel.playMana(message.getMessage(), message.getGameView());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gamePlayXMana")) {
|
else if (callback.getMethod().equals("gamePlayXMana")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.playXMana(message.getMessage(), message.getGameView());
|
panel.playXMana(message.getMessage(), message.getGameView());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameSelectAmount")) {
|
else if (callback.getMethod().equals("gameSelectAmount")) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
|
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("gameUpdate")) {
|
else if (callback.getMethod().equals("gameUpdate")) {
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.updateGame((GameView) callback.getData());
|
panel.updateGame((GameView) callback.getData());
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +197,7 @@ public class Client implements CallbackClient {
|
||||||
|
|
||||||
if (callback.getMessageId() > messageId) {
|
if (callback.getMessageId() > messageId) {
|
||||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
GamePanel panel = session.getGame(callback.getObjectId());
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.inform(message.getMessage(), message.getGameView());
|
panel.inform(message.getMessage(), message.getGameView());
|
||||||
}
|
}
|
||||||
|
|
@ -214,18 +214,18 @@ public class Client implements CallbackClient {
|
||||||
construct(message.getDeck(), message.getTableId(), message.getTime());
|
construct(message.getDeck(), message.getTableId(), message.getTime());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("draftOver")) {
|
else if (callback.getMethod().equals("draftOver")) {
|
||||||
DraftPanel panel = session.getDraft(callback.getObjectId());
|
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.hideDraft();
|
panel.hideDraft();
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("draftPick")) {
|
else if (callback.getMethod().equals("draftPick")) {
|
||||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||||
DraftPanel panel = session.getDraft(callback.getObjectId());
|
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.loadBooster(message.getDraftPickView());
|
panel.loadBooster(message.getDraftPickView());
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("draftUpdate")) {
|
else if (callback.getMethod().equals("draftUpdate")) {
|
||||||
DraftPanel panel = session.getDraft(callback.getObjectId());
|
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||||
if (panel != null)
|
if (panel != null)
|
||||||
panel.updateDraft((DraftView) callback.getData());
|
panel.updateDraft((DraftView) callback.getData());
|
||||||
}
|
}
|
||||||
|
|
@ -238,10 +238,10 @@ public class Client implements CallbackClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("draftInit")) {
|
else if (callback.getMethod().equals("draftInit")) {
|
||||||
session.ack("draftInit");
|
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("tournamentInit")) {
|
else if (callback.getMethod().equals("tournamentInit")) {
|
||||||
session.ack("tournamentInit");
|
|
||||||
}
|
}
|
||||||
messageId = callback.getMessageId();
|
messageId = callback.getMessageId();
|
||||||
}
|
}
|
||||||
|
|
@ -252,7 +252,7 @@ public class Client implements CallbackClient {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getId() throws RemoteException {
|
public UUID getId() {
|
||||||
return clientId;
|
return clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,9 +320,7 @@ public class Client implements CallbackClient {
|
||||||
|
|
||||||
private void handleException(Exception ex) {
|
private void handleException(Exception ex) {
|
||||||
logger.fatal("Client error\n", ex);
|
logger.fatal("Client error\n", ex);
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unrecoverable client error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
|
frame.showError("Error: " + ex.getMessage());
|
||||||
session.disconnect();
|
|
||||||
frame.disableButtons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ import java.util.UUID;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ import mage.client.dialog.JoinTableDialog;
|
||||||
import mage.client.dialog.NewTableDialog;
|
import mage.client.dialog.NewTableDialog;
|
||||||
import mage.client.dialog.NewTournamentDialog;
|
import mage.client.dialog.NewTournamentDialog;
|
||||||
import mage.client.dialog.TableWaitingDialog;
|
import mage.client.dialog.TableWaitingDialog;
|
||||||
import mage.client.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import java.util.UUID;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -36,20 +36,15 @@ package mage.client.tournament;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Observable;
|
|
||||||
import java.util.Observer;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.remote.MageRemoteException;
|
import mage.remote.Session;
|
||||||
import mage.client.remote.Session;
|
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
import mage.view.RoundView;
|
import mage.view.RoundView;
|
||||||
import mage.view.TournamentGameView;
|
import mage.view.TournamentGameView;
|
||||||
|
|
@ -104,7 +99,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
public synchronized void showTournament(UUID tournamentId) {
|
public synchronized void showTournament(UUID tournamentId) {
|
||||||
this.tournamentId = tournamentId;
|
this.tournamentId = tournamentId;
|
||||||
session = MageFrame.getSession();
|
session = MageFrame.getSession();
|
||||||
session.addTournament(tournamentId, this);
|
MageFrame.addTournament(tournamentId, this);
|
||||||
UUID chatRoomId = session.getTournamentChatId(tournamentId);
|
UUID chatRoomId = session.getTournamentChatId(tournamentId);
|
||||||
if (session.joinTournament(tournamentId) && chatRoomId != null) {
|
if (session.joinTournament(tournamentId) && chatRoomId != null) {
|
||||||
this.chatPanel1.connect(chatRoomId);
|
this.chatPanel1.connect(chatRoomId);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package mage.client.util;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.client.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
48
Mage.Common/src/mage/interfaces/MageClient.java
Normal file
48
Mage.Common/src/mage/interfaces/MageClient.java
Normal file
|
|
@ -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 MageClient 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -26,7 +26,11 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.utils;
|
package mage.remote;
|
||||||
|
|
||||||
|
import java.rmi.registry.LocateRegistry;
|
||||||
|
import java.rmi.registry.Registry;
|
||||||
|
import mage.interfaces.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -44,6 +48,39 @@ public class Connection {
|
||||||
private String proxyUsername;
|
private String proxyUsername;
|
||||||
private String proxyPassword;
|
private String proxyPassword;
|
||||||
|
|
||||||
|
// protected Server getServer() {
|
||||||
|
// Server server = null;
|
||||||
|
// try {
|
||||||
|
// Registry reg = LocateRegistry.getRegistry(host, port);
|
||||||
|
// server = (Server) reg.lookup("mage-server");
|
||||||
|
// }
|
||||||
|
// catch (Exception ignored) {}
|
||||||
|
// return server;
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return (host + Integer.toString(port) + proxyType.toString()).hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (! (object instanceof Connection)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Connection otherConnection = (Connection) object;
|
||||||
|
return hashCode() == otherConnection.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return host + ":" + Integer.toString(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getURI() {
|
||||||
|
return "bisocket://" + host + ":" + port;
|
||||||
|
}
|
||||||
|
|
||||||
public ProxyType getProxyType() {
|
public ProxyType getProxyType() {
|
||||||
return proxyType;
|
return proxyType;
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.remote;
|
package mage.remote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.remote;
|
package mage.remote;
|
||||||
|
|
||||||
import java.net.Authenticator;
|
import java.net.Authenticator;
|
||||||
import java.net.PasswordAuthentication;
|
import java.net.PasswordAuthentication;
|
||||||
|
|
@ -35,32 +35,23 @@ import java.rmi.RemoteException;
|
||||||
import java.rmi.registry.LocateRegistry;
|
import java.rmi.registry.LocateRegistry;
|
||||||
import java.rmi.registry.Registry;
|
import java.rmi.registry.Registry;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
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.game.GameException;
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
|
import mage.constants.Constants.SessionState;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentOptions;
|
import mage.game.tournament.TournamentOptions;
|
||||||
|
import mage.interfaces.MageClient;
|
||||||
import mage.interfaces.Server;
|
import mage.interfaces.Server;
|
||||||
import mage.interfaces.ServerState;
|
import mage.interfaces.ServerState;
|
||||||
import mage.interfaces.callback.CallbackClientDaemon;
|
import mage.interfaces.callback.CallbackClientDaemon;
|
||||||
import mage.utils.Connection;
|
|
||||||
import mage.view.DraftPickView;
|
import mage.view.DraftPickView;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
|
@ -79,17 +70,15 @@ public class Session {
|
||||||
|
|
||||||
private UUID sessionId;
|
private UUID sessionId;
|
||||||
private Server server;
|
private Server server;
|
||||||
private Client client;
|
private MageClient client;
|
||||||
private String userName;
|
private String userName;
|
||||||
private MageFrame frame;
|
|
||||||
private ServerState serverState;
|
private ServerState serverState;
|
||||||
private Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
|
private SessionState sessionState = SessionState.DISCONNECTED;
|
||||||
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 CallbackClientDaemon callbackDaemon;
|
||||||
private ScheduledFuture<?> future;
|
private ScheduledFuture<?> future;
|
||||||
private MageUI ui = new MageUI();
|
private Connection connection;
|
||||||
|
private boolean reconnecting = false;
|
||||||
|
private boolean connecting = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For locking session object.
|
* For locking session object.
|
||||||
|
|
@ -100,14 +89,20 @@ public class Session {
|
||||||
*/
|
*/
|
||||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
|
|
||||||
public Session(MageFrame frame) {
|
public Session(MageClient client) {
|
||||||
this.frame = frame;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(Connection connection) {
|
public synchronized boolean connect(Connection connection) {
|
||||||
|
this.connecting = true;
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
disconnect();
|
disconnect(true);
|
||||||
}
|
}
|
||||||
|
this.connection = connection;
|
||||||
|
return connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean connect() {
|
||||||
try {
|
try {
|
||||||
System.setSecurityManager(null);
|
System.setSecurityManager(null);
|
||||||
System.setProperty("http.nonProxyHosts", "code.google.com");
|
System.setProperty("http.nonProxyHosts", "code.google.com");
|
||||||
|
|
@ -131,80 +126,54 @@ public class Session {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort());
|
Registry reg = LocateRegistry.getRegistry(connection.getHost(), connection.getPort());
|
||||||
this.server = (Server) reg.lookup(Config.remoteServer);
|
this.server = (Server) reg.lookup("mage-server");
|
||||||
this.userName = connection.getUsername();
|
this.userName = connection.getUsername();
|
||||||
if (client == null)
|
sessionId = server.registerClient(userName, client.getId(), client.getVersion());
|
||||||
client = new Client(this, frame);
|
|
||||||
sessionId = server.registerClient(userName, client.getId(), frame.getVersion());
|
|
||||||
callbackDaemon = new CallbackClientDaemon(sessionId, client, server);
|
callbackDaemon = new CallbackClientDaemon(sessionId, client, server);
|
||||||
serverState = server.getServerState();
|
serverState = server.getServerState();
|
||||||
future = sessionExecutor.scheduleWithFixedDelay(new ServerPinger(), 5, 5, TimeUnit.SECONDS);
|
future = sessionExecutor.scheduleWithFixedDelay(new ServerPinger(), 5, 5, TimeUnit.SECONDS);
|
||||||
logger.info("Connected to RMI server at " + connection.getHost() + ":" + connection.getPort());
|
logger.info("Connected to RMI server at " + connection.getHost() + ":" + connection.getPort());
|
||||||
frame.setStatusText("Connected to " + connection.getHost() + ":" + connection.getPort() + " ");
|
client.connected("Connected to " + connection.getHost() + ":" + connection.getPort() + " ");
|
||||||
frame.enableButtons();
|
reconnecting = false;
|
||||||
|
connecting = false;
|
||||||
return true;
|
return true;
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
logger.fatal("", ex);
|
logger.fatal("", ex);
|
||||||
disconnect();
|
if (!reconnecting) {
|
||||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
disconnect(false);
|
||||||
|
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||||
|
}
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
logger.fatal("Unable to connect to server - ", ex);
|
logger.fatal("Unable to connect to server - ", ex);
|
||||||
disconnect();
|
if (!reconnecting) {
|
||||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
disconnect(false);
|
||||||
|
client.showMessage("Unable to connect to server. " + ex.getMessage());
|
||||||
|
}
|
||||||
} catch (NotBoundException ex) {
|
} catch (NotBoundException ex) {
|
||||||
logger.fatal("Unable to connect to server - ", ex);
|
logger.fatal("Unable to connect to server - ", ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public synchronized void disconnect(boolean showMessage) {
|
||||||
|
if (sessionState == SessionState.CONNECTED)
|
||||||
if (isConnected()) {
|
sessionState = SessionState.DISCONNECTING;
|
||||||
|
if (connection == null)
|
||||||
|
return;
|
||||||
|
if (sessionState == SessionState.CONNECTED) {
|
||||||
try {
|
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);
|
server.deregisterClient(sessionId);
|
||||||
} catch (RemoteException ex) {
|
} catch (Exception ex) {
|
||||||
logger.fatal("Error disconnecting ...", ex);
|
|
||||||
} catch (MageException ex) {
|
|
||||||
logger.fatal("Error disconnecting ...", ex);
|
logger.fatal("Error disconnecting ...", ex);
|
||||||
}
|
}
|
||||||
removeServer();
|
|
||||||
}
|
}
|
||||||
}
|
client.disconnected();
|
||||||
|
|
||||||
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 ... ");
|
logger.info("Disconnected ... ");
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Disconnected.", "Disconnected", JOptionPane.INFORMATION_MESSAGE);
|
if (sessionState == SessionState.SERVER_UNAVAILABLE && showMessage) {
|
||||||
|
client.showError("Server error. You have been disconnected");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
public void ack(String message) {
|
sessionState = SessionState.DISCONNECTED;
|
||||||
try {
|
|
||||||
server.ack(message, sessionId);
|
|
||||||
} catch (RemoteException ex) {
|
|
||||||
handleRemoteException(ex);
|
|
||||||
} catch (MageException ex) {
|
|
||||||
handleMageException(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,7 +189,7 @@ public class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return server != null;
|
return sessionState == SessionState.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getPlayerTypes() {
|
public String[] getPlayerTypes() {
|
||||||
|
|
@ -245,30 +214,6 @@ public class Session {
|
||||||
return false;
|
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() {
|
public UUID getMainRoomId() {
|
||||||
try {
|
try {
|
||||||
return server.getMainRoomId();
|
return server.getMainRoomId();
|
||||||
|
|
@ -475,10 +420,9 @@ public class Session {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinChat(UUID chatId, ChatPanel chat) {
|
public boolean joinChat(UUID chatId) {
|
||||||
try {
|
try {
|
||||||
server.joinChat(chatId, sessionId, userName);
|
server.joinChat(chatId, sessionId, userName);
|
||||||
chats.put(chatId, chat);
|
|
||||||
return true;
|
return true;
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
handleRemoteException(ex);
|
handleRemoteException(ex);
|
||||||
|
|
@ -493,7 +437,6 @@ public class Session {
|
||||||
try {
|
try {
|
||||||
if (server == null) return false;
|
if (server == null) return false;
|
||||||
server.leaveChat(chatId, sessionId);
|
server.leaveChat(chatId, sessionId);
|
||||||
chats.remove(chatId);
|
|
||||||
return true;
|
return true;
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
handleRemoteException(ex);
|
handleRemoteException(ex);
|
||||||
|
|
@ -785,19 +728,17 @@ public class Session {
|
||||||
|
|
||||||
private void handleRemoteException(RemoteException ex) {
|
private void handleRemoteException(RemoteException ex) {
|
||||||
logger.fatal("Communication error", ex);
|
logger.fatal("Communication error", ex);
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Critical server error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
|
disconnect(false);
|
||||||
disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMageException(MageException ex) {
|
private void handleMageException(MageException ex) {
|
||||||
logger.fatal("Server error", ex);
|
logger.fatal("Server error", ex);
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Critical server error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);
|
disconnect(false);
|
||||||
disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleGameException(GameException ex) {
|
private void handleGameException(GameException ex) {
|
||||||
logger.warn(ex.getMessage());
|
logger.warn(ex.getMessage());
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
client.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -805,14 +746,6 @@ public class Session {
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MageUI getUI() {
|
|
||||||
return ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Server getServerRef() {
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ServerPinger implements Runnable {
|
class ServerPinger implements Runnable {
|
||||||
|
|
||||||
private int missed = 0;
|
private int missed = 0;
|
||||||
|
|
@ -823,7 +756,7 @@ public class Session {
|
||||||
missed++;
|
missed++;
|
||||||
if (missed > 10) {
|
if (missed > 10) {
|
||||||
logger.info("Connection to server timed out");
|
logger.info("Connection to server timed out");
|
||||||
removeServer();
|
disconnect(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue