fixed some timing errors

This commit is contained in:
BetaSteward 2010-10-29 01:59:45 +00:00
parent 875614b96c
commit 93120eedea
3 changed files with 13 additions and 5 deletions

View file

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

View file

@ -174,7 +174,9 @@ public class GameController implements GameCallback {
private synchronized void startGame() {
if (gameFuture == null) {
for (final Entry<UUID, GameSession> 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);

View file

@ -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) {