forked from External/mage
fixed issue 25 - server waits for all clients to confirm initialization before starting game
This commit is contained in:
parent
f81c238994
commit
3ca748e16d
9 changed files with 56 additions and 45 deletions
|
|
@ -60,13 +60,23 @@ public class GameWatcher {
|
|||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null) {
|
||||
session.clearAck();
|
||||
session.fireCallback(new ClientCallback("gameInit", gameView));
|
||||
return true;
|
||||
if (waitForAck("gameInit"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean waitForAck(String message) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
do {
|
||||
//TODO: add timeout
|
||||
} while (!session.getAckMessage().equals(message) && !killed);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void update(final GameView gameView) {
|
||||
if (!killed) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue