From 93120eedea8b44266cd6e8b606dbe9a6177dfeb5 Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Fri, 29 Oct 2010 01:59:45 +0000 Subject: [PATCH] fixed some timing errors --- Mage.Client/src/main/java/mage/client/remote/Client.java | 7 +++++-- Mage.Server/src/mage/server/game/GameController.java | 4 +++- Mage.Server/src/mage/server/game/GameWatcher.java | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/remote/Client.java b/Mage.Client/src/main/java/mage/client/remote/Client.java index 387c269093..38707263d7 100644 --- a/Mage.Client/src/main/java/mage/client/remote/Client.java +++ b/Mage.Client/src/main/java/mage/client/remote/Client.java @@ -34,6 +34,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import mage.client.MageFrame; +import mage.client.chat.ChatPanel; import mage.interfaces.callback.CallbackClient; import mage.interfaces.callback.ClientCallback; import mage.util.Logging; @@ -81,7 +82,9 @@ public class Client implements CallbackClient { } else if (callback.getMethod().equals("chatMessage")) { ChatMessage message = (ChatMessage) callback.getData(); - session.getChats().get(message.getChatId()).receiveMessage(message.getMessage(), message.getColor()); + ChatPanel panel = session.getChats().get(message.getChatId()); + if (panel != null) + panel.receiveMessage(message.getMessage(), message.getColor()); } else if (callback.getMethod().equals("replayInit")) { session.getGame().init((GameView) callback.getData()); @@ -189,7 +192,7 @@ public class Client implements CallbackClient { } private void handleException(Exception ex) { - logger.log(Level.SEVERE, "Client error", ex); + logger.log(Level.SEVERE, "Client error\n", ex); JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unrecoverable client error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE); session.disconnect(); frame.disableButtons(); diff --git a/Mage.Server/src/mage/server/game/GameController.java b/Mage.Server/src/mage/server/game/GameController.java index 3e3ef26e29..14ea816b7a 100644 --- a/Mage.Server/src/mage/server/game/GameController.java +++ b/Mage.Server/src/mage/server/game/GameController.java @@ -174,7 +174,9 @@ public class GameController implements GameCallback { private synchronized void startGame() { if (gameFuture == null) { for (final Entry entry: gameSessions.entrySet()) { - entry.getValue().init(getGameView(entry.getKey())); + if (!entry.getValue().init(getGameView(entry.getKey()))) { + logger.severe("Unable to initialize client"); + } } GameWorker worker = new GameWorker(game, this); gameFuture = gameExecutor.submit(worker); diff --git a/Mage.Server/src/mage/server/game/GameWatcher.java b/Mage.Server/src/mage/server/game/GameWatcher.java index 337e9045fd..a13ad35bc5 100644 --- a/Mage.Server/src/mage/server/game/GameWatcher.java +++ b/Mage.Server/src/mage/server/game/GameWatcher.java @@ -56,12 +56,15 @@ public class GameWatcher { this.gameId = gameId; } - public void init(final GameView gameView) { + public boolean init(final GameView gameView) { if (!killed) { Session session = SessionManager.getInstance().getSession(sessionId); - if (session != null) + if (session != null) { session.fireCallback(new ClientCallback("gameInit", gameView)); + return true; + } } + return false; } public void update(final GameView gameView) {