Skip to content

Instantly share code, notes, and snippets.

@brantz
Created February 23, 2011 21:32
Show Gist options
  • Save brantz/841226 to your computer and use it in GitHub Desktop.
Save brantz/841226 to your computer and use it in GitHub Desktop.
updateloop.java
public void tradeAcceptUpdateLoop() {
if (model.getTradingOfferStatus() == 2) {
log.log(Level.INFO, model.getPlayerColor()
+ "'s trade offer was accepted.");
killTimer();
Window.alert("Your trade offer was accepted");
} else if (model.getTradingOfferStatus() == 0) {
log.log(Level.INFO, model.getPlayerColor()
+ "'s trade offer was declined.");
killTimer();
Window.alert("Your trade offer was declined.");
} else {
timer = new Timer() {
@Override
public void run() {
try {
log.log(Level.INFO, model.getPlayerColor()
+ " waiting for answer to trade offer");
communicationService.getTradingOfferStatus();
tradeAcceptUpdateLoop();
} catch (Exception e) {
log.log(Level.SEVERE, model.getPlayerColor()
+ " exception while waiting for trade answer: "
+ e.getMessage());
}
}
};
if (model.getTradingOfferStatus() == 1) {
timer.schedule(5000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment