This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tickCancellable: Option[Cancellable] = None | |
override def receiveCommand = { | |
// ... | |
case TickCountdown => game match { | |
case rg: RunningGame => handleChanges(rg.tickCountdown()) | |
case _ => | |
log.warning("Game is not running, cannot update countdown") | |
cancelCountdownTick() | |
} | |
} | |
def scheduleCountdownTick() = { | |
val cancellable = | |
system.scheduler.schedule(1.second, 1.seconds, self, TickCountdown) | |
tickCancellable = Some(cancellable) | |
} | |
def cancelCountdownTick() = { | |
tickCancellable.foreach(_.cancel()) | |
tickCancellable = None | |
} | |
override def receiveRecover = { | |
// ... | |
case RecoveryCompleted => | |
if (game.isRunning) | |
scheduleCountdownTick() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment