Need to implement serverside timer using Play Fram

2019-06-14 04:42发布

My question:

How can I implement a timer for an auction?

  • Timer needs to run on the server
  • Since there are going to be many timers I don't want to waste a lot of resources on the function that runs the timer.

I am using play framework 2.1.1 and AKKA.

Can I store the timer in the database? updating it on retrieval?

1条回答
贼婆χ
2楼-- · 2019-06-14 05:14

I guess you can get inspiration from the Java Comet Clock sample coming with Play framework

https://github.com/playframework/Play20/tree/master/samples/java/comet-clock

It use Akka for scheduling and Comet to push data to clients. Maybe your can use a better push solution like websockets or server sent events (you can check the websocket chat sample for that)

And if you need to store the timer in a DB, you can do that in the Clock Actor (or equivalent).

查看更多
登录 后发表回答