forked from External/mage
client/server overhaul - tested on localhost, remote testing pending
This commit is contained in:
parent
ecbd843fb7
commit
892f7cce1b
90 changed files with 4448 additions and 500 deletions
|
|
@ -31,10 +31,13 @@ package mage.server.game;
|
|||
import java.util.UUID;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
import mage.MageException;
|
||||
import mage.interfaces.callback.CallbackException;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.Session;
|
||||
import mage.server.SessionManager;
|
||||
import mage.view.GameView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -42,6 +45,7 @@ import mage.view.GameView;
|
|||
*/
|
||||
public class ReplaySession implements GameCallback {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ReplaySession.class);
|
||||
private GameReplay replay;
|
||||
protected UUID sessionId;
|
||||
|
||||
|
|
@ -53,8 +57,13 @@ public class ReplaySession implements GameCallback {
|
|||
public void replay() {
|
||||
replay.start();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null)
|
||||
session.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame())));
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame())));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("replay init exception", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
|
@ -72,8 +81,13 @@ public class ReplaySession implements GameCallback {
|
|||
@Override
|
||||
public void gameResult(final String result) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null)
|
||||
session.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result));
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("replay done exception", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateGame(final GameState state, Game game) {
|
||||
|
|
@ -82,8 +96,13 @@ public class ReplaySession implements GameCallback {
|
|||
}
|
||||
else {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null)
|
||||
session.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game)));
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("replay update exception", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue