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