round remote socket WIP (TV)
parent
661d7e9832
commit
203e5d49b5
|
@ -191,7 +191,7 @@ package game {
|
|||
}
|
||||
|
||||
package tv {
|
||||
case class Select(msg: JsObject)
|
||||
case class TvSelect(gameId: String, speed: chess.Speed, data: JsObject)
|
||||
}
|
||||
|
||||
package notify {
|
||||
|
|
|
@ -10,10 +10,11 @@ import actorApi.round._
|
|||
import chess.format.Uci
|
||||
import chess.{ Color, White, Black, Speed, Centis, MoveMetrics }
|
||||
import lila.chat.Chat
|
||||
import lila.common.{ Bus, IpAddress }
|
||||
import lila.common.IpAddress
|
||||
import lila.game.Game.{ PlayerId, FullId }
|
||||
import lila.game.{ Game, Event }
|
||||
import lila.hub.actorApi.round.{ Berserk, RematchYes, RematchNo, Abort, Resign }
|
||||
import lila.hub.actorApi.tv.TvSelect
|
||||
import lila.hub.DuctConcMap
|
||||
import lila.room.RoomSocket.{ Protocol => RP, _ }
|
||||
import lila.socket.RemoteSocket.{ Protocol => P, _ }
|
||||
|
@ -113,6 +114,9 @@ final class RoundRemoteSocket(
|
|||
remoteSocketApi.subscribe("r-in", Protocol.In.reader)(
|
||||
roundHandler orElse remoteSocketApi.baseHandler
|
||||
)
|
||||
system.lilaBus.subscribeFun('tvSelect) {
|
||||
case TvSelect(gameId, speed, json) => send(Protocol.Out.tvSelect(gameId, speed, json))
|
||||
}
|
||||
|
||||
private val terminationDelay = new TerminationDelay(system.scheduler, 1 minutes, finishRound)
|
||||
}
|
||||
|
@ -186,7 +190,7 @@ object RoundRemoteSocket {
|
|||
Flag(Game.Id(gameId), _, P.In.optional(playerId) map PlayerId.apply)
|
||||
}
|
||||
}
|
||||
case "r/tv" => raw.get(2) {
|
||||
case "r/tv/user" => raw.get(2) {
|
||||
case Array(gameId, userId) => UserTv(Game.Id(gameId), userId).some
|
||||
}
|
||||
case _ => RP.In.reader(raw)
|
||||
|
@ -220,7 +224,10 @@ object RoundRemoteSocket {
|
|||
}
|
||||
|
||||
def userTvNewGame(gameId: Game.Id, userId: User.ID) =
|
||||
s"r/tv $gameId $userId"
|
||||
s"r/tv/user $gameId $userId"
|
||||
|
||||
def tvSelect(gameId: Game.ID, speed: chess.Speed, data: JsObject) =
|
||||
s"tv/select $gameId ${speed.id} ${Json stringify data}"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@ import lila.common.LightUser
|
|||
import lila.game.actorApi.{ StartGame, UserStartGame }
|
||||
import lila.game.{ Game, Event }
|
||||
import lila.hub.actorApi.Deploy
|
||||
import lila.hub.actorApi.game.ChangeFeatured
|
||||
import lila.hub.actorApi.round.{ IsOnGame, TourStanding }
|
||||
import lila.hub.actorApi.simul.GetHostIds
|
||||
import lila.hub.actorApi.tv.{ Select => TvSelect }
|
||||
import lila.hub.Trouper
|
||||
import lila.socket._
|
||||
import lila.socket.actorApi.{ Connected => _, _ }
|
||||
|
@ -241,10 +239,6 @@ private[round] final class RoundSocket(
|
|||
)
|
||||
))
|
||||
|
||||
case ChangeFeatured(_, msg) => foreachWatcher(_ push msg)
|
||||
|
||||
case TvSelect(msg) => foreachWatcher(_ push msg)
|
||||
|
||||
case UserStartGame(userId, game) => foreachWatcher { m =>
|
||||
if (m.onUserTv(userId) && !m.userId.exists(game.userIds.contains))
|
||||
m push makeMessage("resync")
|
||||
|
|
|
@ -63,7 +63,7 @@ private[tv] final class TvTrouper(
|
|||
case (u, r) => channelChampions += (channel -> Tv.Champion(u, r, game.id))
|
||||
}
|
||||
onSelect(game)
|
||||
selectChannel ! lila.socket.Channel.Publish(makeMessage("tvSelect", Json.obj(
|
||||
val data = Json.obj(
|
||||
"channel" -> channel.key,
|
||||
"id" -> game.id,
|
||||
"color" -> game.firstColor.name,
|
||||
|
@ -74,7 +74,9 @@ private[tv] final class TvTrouper(
|
|||
"rating" -> player.rating
|
||||
)
|
||||
}
|
||||
)))
|
||||
)
|
||||
selectChannel ! lila.socket.Channel.Publish(makeMessage("tvSelect", data)) // TODO remove: old rounds
|
||||
system.lilaBus.publish(lila.hub.actorApi.tv.TvSelect(game.id, game.speed, data), 'tvSelect) // new rounds
|
||||
if (channel == Tv.Channel.Best) {
|
||||
implicit def timeout = makeTimeout(100 millis)
|
||||
actorAsk(rendererActor, actorApi.RenderFeaturedJs(game)) onSuccess {
|
||||
|
|
Loading…
Reference in New Issue