Created
July 27, 2015 16:17
-
-
Save LukasGasior1/88b05f530bcad0069c60 to your computer and use it in GitHub Desktop.
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
class GetStatsRequestActor( | |
ctx: RequestContext, | |
statsActor: ActorRef)(implicit override val json4sFormats: Formats) | |
extends Actor | |
with Json4sSupport { | |
statsActor ! StatsActor.GetState | |
context.setReceiveTimeout(2.seconds) | |
override def receive = { | |
case stats: Stats => | |
val rollsCounts = stats.rollsCounts | |
.map(RollCount.tupled) | |
.toSeq | |
.sortBy(_.rollsCount) | |
.reverse | |
ctx.complete(StatsResponseData(rollsCounts)) | |
context stop self | |
case ReceiveTimeout => | |
ctx.complete(StatusCodes.RequestTimeout) | |
context stop self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment