Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

randomly delay websocket resync

  • Loading branch information...
commit c05caf37c610125d74b30d4ba48225d61de9c0c2 1 parent 7590f69
@ornicar authored
Showing with 12 additions and 4 deletions.
  1. +11 −3 app/socket/HubActor.scala
  2. +1 −1  app/tournament/Socket.scala
View
14 app/socket/HubActor.scala
@@ -5,6 +5,7 @@ import memo.BooleanExpiryMemo
import akka.actor._
import play.api.libs.json._
+import scala.util.Random
abstract class HubActor[M <: SocketMember](uidTimeout: Int) extends Actor {
@@ -86,11 +87,18 @@ abstract class HubActor[M <: SocketMember](uidTimeout: Int) extends Actor {
members = members - uid
}
- def resync(member: M) {
- member.channel push makeMessage("resync", JsNull)
+ private lazy val resyncMessage = makeMessage("resync", JsNull)
+
+ protected def resync(member: M) {
+ import play.api.libs.concurrent._
+ import play.api.Play.current
+ import akka.util.duration._
+ Akka.system.scheduler.scheduleOnce((Random nextInt 4).seconds) {
+ member.channel push resyncMessage
+ }
}
- def resync(uid: String) {
+ protected def resync(uid: String) {
withMember(uid)(resync)
}
View
2  app/tournament/Socket.scala
@@ -14,7 +14,7 @@ import scalaz.effects._
import user.User
import game.DbGame
-import socket.{ PingVersion, Quit, Resync, LiveGames }
+import socket.{ PingVersion, Quit, LiveGames }
import socket.Util.connectionFail
import security.Flood
import implicits.RichJs._
Please sign in to comment.
Something went wrong with that request. Please try again.