only push featured game moves in TV broadcast
parent
c303db1ac4
commit
9ad4263df0
|
@ -37,7 +37,7 @@ final class Featured(
|
|||
oneId = game.id.some
|
||||
rendererActor ? actorApi.RenderFeaturedJs(game) onSuccess {
|
||||
case html: Html =>
|
||||
bus.publish(lila.hub.actorApi.game.ChangeFeatured(html), 'changeFeaturedGame)
|
||||
bus.publish(lila.hub.actorApi.game.ChangeFeatured(game.id, html), 'changeFeaturedGame)
|
||||
}
|
||||
GameRepo setTv game.id
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ case class Propagate(data: Atom, propagations: List[Propagation] = Nil) {
|
|||
}
|
||||
|
||||
package game {
|
||||
case class ChangeFeatured(html: Html)
|
||||
case class ChangeFeatured(id: String, html: Html)
|
||||
case object Count
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,21 @@ private final class TvBroadcast extends Actor {
|
|||
|
||||
private val (enumerator, channel) = Concurrent.broadcast[JsValue]
|
||||
|
||||
private var featuredId = none[String]
|
||||
|
||||
def receive = {
|
||||
|
||||
case TvBroadcast.GetEnumerator => sender ! enumerator
|
||||
|
||||
case ChangeFeatured(html) =>
|
||||
case ChangeFeatured(id, html) =>
|
||||
featuredId = id.some
|
||||
channel push makeMessage("featured", Json.obj("html" -> html.toString))
|
||||
|
||||
case move: MoveEvent => channel push makeMessage("fen", Json.obj(
|
||||
"fen" -> move.fen,
|
||||
"lm" -> move.move
|
||||
))
|
||||
case move: MoveEvent if Some(move.gameId) == featuredId =>
|
||||
channel push makeMessage("fen", Json.obj(
|
||||
"fen" -> move.fen,
|
||||
"lm" -> move.move
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ abstract class SocketActor[M <: SocketMember](uidTtl: Duration) extends Socket w
|
|||
|
||||
// the actor instance must subscribe to 'changeFeaturedGame to receive this message
|
||||
// context.system.lilaBus.subscribe(self, 'changeFeaturedGame)
|
||||
case ChangeFeatured(html) => notifyFeatured(html)
|
||||
case ChangeFeatured(_, html) => notifyFeatured(html)
|
||||
}
|
||||
|
||||
def receive = receiveSpecific orElse receiveGeneric
|
||||
|
|
Loading…
Reference in New Issue