removed the Session out of local scope and introduced a static SessionHandler that acts as interface to remote.Session

This commit is contained in:
ingmargoudt 2016-09-15 20:52:41 +02:00
parent 360823ec2e
commit 3019991473
28 changed files with 545 additions and 271 deletions

View file

@ -63,6 +63,7 @@ import javax.swing.Timer;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.components.tray.MageTray;
import mage.client.deckeditor.SortSettingDraft;
import mage.client.dialog.PreferencesDialog;
@ -75,7 +76,6 @@ import mage.client.util.Listener;
import mage.client.util.audio.AudioManager;
import mage.client.util.gui.BufferedImageBuilder;
import mage.constants.PlayerAction;
import mage.remote.Session;
import mage.view.CardsView;
import mage.view.DraftPickView;
import mage.view.DraftView;
@ -93,7 +93,6 @@ public class DraftPanel extends javax.swing.JPanel {
private static final Logger LOGGER = Logger.getLogger(DraftPanel.class);
private UUID draftId;
private Session session;
private Timer countdown;
private int timeout;
@ -183,9 +182,8 @@ public class DraftPanel extends javax.swing.JPanel {
public synchronized void showDraft(UUID draftId) {
this.draftId = draftId;
session = MageFrame.getSession();
MageFrame.addDraft(draftId, this);
if (!session.joinDraft(draftId)) {
if (!SessionHandler.joinDraft(draftId)) {
hideDraft();
}
@ -334,7 +332,7 @@ public class DraftPanel extends javax.swing.JPanel {
public void event(Event event) {
if (event.getEventName().equals("pick-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
DraftPickView view = session.sendCardPick(draftId, source.getId(), cardsHidden);
DraftPickView view = SessionHandler.sendCardPick(draftId, source.getId(), cardsHidden);
if (view != null) {
loadCardsToPickedCardsArea(view.getPicks());
draftBooster.loadBooster(EMPTY_VIEW, bigCard);
@ -344,7 +342,7 @@ public class DraftPanel extends javax.swing.JPanel {
}
if (event.getEventName().equals("mark-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
session.sendCardMark(draftId, source.getId());
SessionHandler.sendCardMark(draftId, source.getId());
}
}
}