mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
rolled back changes since 0.7.3 R2 - going to switch client/server architecture
This commit is contained in:
parent
1f72804968
commit
c38804af5f
103 changed files with 997 additions and 4921 deletions
|
|
@ -82,11 +82,7 @@ public class ChatSession {
|
|||
for (UUID sessionId: clients.keySet()) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null)
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("broadcast error", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("chatMessage", chatId, new ChatMessage(username, msg, time, color)));
|
||||
else
|
||||
kill(sessionId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,16 +38,13 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.logging.Level;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.game.GameException;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.InvalidDeckException;
|
||||
import mage.game.match.MatchOptions;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.interfaces.Server;
|
||||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.CallbackException;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.draft.DraftManager;
|
||||
|
|
@ -108,8 +105,8 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void ack(int messageId, UUID sessionId) throws RemoteException, CallbackException {
|
||||
SessionManager.getInstance().getSession(sessionId).ack(messageId);
|
||||
public void ack(String message, UUID sessionId) throws RemoteException, MageException {
|
||||
SessionManager.getInstance().getSession(sessionId).ack(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -212,13 +209,9 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
catch (InvalidDeckException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (GameException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ex instanceof GameException)
|
||||
throw (GameException)ex;
|
||||
handleException(ex);
|
||||
}
|
||||
return false;
|
||||
|
|
@ -233,10 +226,9 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
catch (GameException ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ex instanceof GameException)
|
||||
throw (GameException)ex;
|
||||
handleException(ex);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -30,12 +30,7 @@ package mage.server;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.GameException;
|
||||
import mage.MageException;
|
||||
import mage.interfaces.callback.CallbackAck;
|
||||
import mage.interfaces.callback.CallbackException;
|
||||
import mage.interfaces.callback.CallbackServerSession;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.game.GameManager;
|
||||
|
|
@ -55,12 +50,11 @@ public class Session {
|
|||
private String username;
|
||||
private String host;
|
||||
private int messageId = 0;
|
||||
private String ackMessage;
|
||||
private Date timeConnected;
|
||||
private long lastPing;
|
||||
private boolean isAdmin = false;
|
||||
private boolean killed = false;
|
||||
private final CallbackServerSession callback = new CallbackServerSession();
|
||||
private final CallbackAck ackResponse = new CallbackAck();
|
||||
|
||||
public Session(String userName, String host, UUID clientId) {
|
||||
sessionId = UUID.randomUUID();
|
||||
|
|
@ -90,10 +84,6 @@ public class Session {
|
|||
}
|
||||
|
||||
public void kill() {
|
||||
this.killed = true;
|
||||
synchronized(ackResponse) {
|
||||
ackResponse.notify();
|
||||
}
|
||||
SessionManager.getInstance().removeSession(sessionId);
|
||||
TableManager.getInstance().removeSession(sessionId);
|
||||
GameManager.getInstance().removeSession(sessionId);
|
||||
|
|
@ -109,116 +99,55 @@ public class Session {
|
|||
return null;
|
||||
}
|
||||
|
||||
public synchronized void fireCallback(final ClientCallback call) throws CallbackException {
|
||||
public synchronized void fireCallback(final ClientCallback call) {
|
||||
call.setMessageId(messageId++);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(sessionId + " - " + call.getMessageId() + " - " + call.getMethod());
|
||||
try {
|
||||
int retryCount = 0;
|
||||
while (retryCount < 3) {
|
||||
callback.setCallback(call);
|
||||
if (waitForAck(call.getMessageId()))
|
||||
return;
|
||||
retryCount++;
|
||||
try {
|
||||
Thread.sleep(2000 * retryCount);
|
||||
}
|
||||
catch (InterruptedException ignored) {}
|
||||
}
|
||||
callback.setCallback(call);
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Session fireCallback error", ex);
|
||||
}
|
||||
throw new CallbackException("Callback failed for " + call.getMethod());
|
||||
}
|
||||
|
||||
protected boolean waitForAck(int messageId) {
|
||||
ackResponse.clear();
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(sessionId + " - waiting for ack: " + messageId);
|
||||
synchronized(ackResponse) {
|
||||
try {
|
||||
if (!ackResponse.isAck())
|
||||
ackResponse.wait(10000);
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (!ackResponse.isAck())
|
||||
logger.debug(sessionId + " - ack timed out waiting for " + messageId);
|
||||
else
|
||||
logger.debug(sessionId + " - ack received: " + messageId);
|
||||
}
|
||||
return ackResponse.getValue() == messageId;
|
||||
} catch (InterruptedException ex) { }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void gameStarted(final UUID gameId, final UUID playerId) throws GameException {
|
||||
try {
|
||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("gameStarted exception", ex);
|
||||
throw new GameException("callback failed");
|
||||
}
|
||||
public void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
||||
}
|
||||
|
||||
public void draftStarted(final UUID draftId, final UUID playerId) throws MageException {
|
||||
try {
|
||||
fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draftStarted exception", ex);
|
||||
throw new MageException("callback failed");
|
||||
}
|
||||
public void draftStarted(final UUID draftId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startDraft", draftId, new TableClientMessage(draftId, playerId)));
|
||||
}
|
||||
|
||||
public void tournamentStarted(final UUID tournamentId, final UUID playerId) throws MageException {
|
||||
try {
|
||||
fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("tournamentStarted exception", ex);
|
||||
throw new MageException("callback failed");
|
||||
}
|
||||
public void tournamentStarted(final UUID tournamentId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startTournament", tournamentId, new TableClientMessage(tournamentId, playerId)));
|
||||
}
|
||||
|
||||
public void sideboard(final Deck deck, final UUID tableId, final int time) throws MageException {
|
||||
try {
|
||||
fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("sideboard exception", ex);
|
||||
throw new MageException("callback failed");
|
||||
}
|
||||
public void sideboard(final Deck deck, final UUID tableId, final int time) {
|
||||
fireCallback(new ClientCallback("sideboard", tableId, new TableClientMessage(deck, tableId, time)));
|
||||
}
|
||||
|
||||
public void construct(final Deck deck, final UUID tableId, final int time) throws MageException {
|
||||
try {
|
||||
fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("construct exception", ex);
|
||||
throw new MageException("callback failed");
|
||||
}
|
||||
public void construct(final Deck deck, final UUID tableId, final int time) {
|
||||
fireCallback(new ClientCallback("construct", tableId, new TableClientMessage(deck, tableId, time)));
|
||||
}
|
||||
|
||||
public void watchGame(final UUID gameId) throws MageException {
|
||||
try {
|
||||
fireCallback(new ClientCallback("watchGame", gameId));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("watchGame exception", ex);
|
||||
throw new MageException("callback failed");
|
||||
}
|
||||
public void watchGame(final UUID gameId) {
|
||||
fireCallback(new ClientCallback("watchGame", gameId));
|
||||
}
|
||||
|
||||
public void replayGame(final UUID gameId) {
|
||||
try {
|
||||
fireCallback(new ClientCallback("replayGame", gameId));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("replayGame exception", ex);
|
||||
}
|
||||
fireCallback(new ClientCallback("replayGame", gameId));
|
||||
}
|
||||
|
||||
public void ack(int messageId) {
|
||||
synchronized(ackResponse) {
|
||||
ackResponse.setAck(true);
|
||||
ackResponse.setValue(messageId);
|
||||
ackResponse.notify();
|
||||
}
|
||||
public void ack(String message) {
|
||||
this.ackMessage = message;
|
||||
}
|
||||
|
||||
public String getAckMessage() {
|
||||
return ackMessage;
|
||||
}
|
||||
|
||||
public void clearAck() {
|
||||
this.ackMessage = "";
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
|
|
|||
|
|
@ -209,13 +209,8 @@ public class TableController {
|
|||
if (table.getState() != TableState.DUELING) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
SessionManager.getInstance().getSession(sessionId).watchGame(match.getGame().getId());
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
logger.fatal("watchTable error", ex);
|
||||
}
|
||||
return false;
|
||||
SessionManager.getInstance().getSession(sessionId).watchGame(match.getGame().getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean replayTable(UUID sessionId) {
|
||||
|
|
@ -341,12 +336,8 @@ public class TableController {
|
|||
table.initDraft();
|
||||
DraftManager.getInstance().createDraftSession(draft, sessionPlayerMap, table.getId());
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
try {
|
||||
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
sessionManager.getSession(entry.getKey()).draftStarted(draft.getId(), entry.getValue());
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
logger.fatal("startDraft error", ex);
|
||||
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
sessionManager.getSession(entry.getKey()).draftStarted(draft.getId(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,13 +72,8 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftInit", draft.getId(), draftView));
|
||||
return true;
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("Unable to start draft ", ex);
|
||||
return false;
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftInit", draft.getId(), draftView));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -96,11 +91,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftUpdate", draft.getId(), draftView));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("update draft exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftUpdate", draft.getId(), draftView));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -109,11 +100,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(draftView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draft inform exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftInform", draft.getId(), new DraftClientMessage(draftView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -122,11 +109,7 @@ public class DraftSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftOver", draft.getId()));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draft end exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftOver", draft.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,11 +119,7 @@ public class DraftSession {
|
|||
setupTimeout(timeout);
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(draftPickView)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("draft pick exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("draftPick", draft.getId(), new DraftClientMessage(draftPickView)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(gameView, question)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game ask exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameAsk", game.getId(), new GameClientMessage(gameView, question)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,11 +81,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(gameView, question, cardView, targets, required, options)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game target exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameTarget", game.getId(), new GameClientMessage(gameView, question, cardView, targets, required, options)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,11 +91,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(gameView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game select exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameSelect", game.getId(), new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,11 +101,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game choose ability exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameChooseAbility", game.getId(), abilities));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -127,11 +111,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[0]), message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game choose exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[0]), message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,11 +121,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(gameView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game play mana exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gamePlayMana", game.getId(), new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -155,11 +131,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(gameView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game play x mana exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gamePlayXMana", game.getId(), new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -169,11 +141,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game select amount exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameSelectAmount", game.getId(), new GameClientMessage(message, min, max)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -182,11 +150,7 @@ public class GameSession extends GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game reveal exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameReveal", game.getId(), new GameClientMessage(cardView, name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,13 +61,8 @@ public class GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameInit", gameId, gameView));
|
||||
return true;
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("Unable to start watching ", ex);
|
||||
return false;
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameInit", gameId, gameView));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -77,11 +72,7 @@ public class GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameUpdate", gameId, gameView));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game update exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameUpdate", gameId, gameView));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,11 +81,7 @@ public class GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameInform", gameId, new GameClientMessage(gameView, message)));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game inform exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameInform", gameId, new GameClientMessage(gameView, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,11 +90,7 @@ public class GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("gameOver", gameId, message));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("game select exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("gameOver", gameId, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,11 +58,7 @@ public class ReplaySession implements GameCallback {
|
|||
replay.start();
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("replayInit", replay.getGame().getId(), new GameView(replay.next(), replay.getGame())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,11 +78,7 @@ public class ReplaySession implements GameCallback {
|
|||
public void gameResult(final String result) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("replay done exception", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("replayDone", replay.getGame().getId(), result));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,11 +89,7 @@ public class ReplaySession implements GameCallback {
|
|||
else {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
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);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("replayUpdate", replay.getGame().getId(), new GameView(state, game)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,12 +72,8 @@ public class TournamentSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("tournamentInit", tournament.getId(), tournamentView));
|
||||
return true;
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("Unable to start tournament", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("tournamentInit", tournament.getId(), tournamentView));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -95,11 +91,7 @@ public class TournamentSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("tournamentUpdate", tournament.getId(), tournamentView));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("tournament update error", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("tournamentUpdate", tournament.getId(), tournamentView));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -108,11 +100,7 @@ public class TournamentSession {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
try {
|
||||
session.fireCallback(new ClientCallback("tournamentOver", tournament.getId(), message));
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("tournament over error", ex);
|
||||
}
|
||||
session.fireCallback(new ClientCallback("tournamentOver", tournament.getId(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue