propagate fen events to tournament hubs

pull/83/head
Thibault Duplessis 2012-09-16 12:38:39 +02:00
parent 3629a4bf9e
commit f341a2255c
8 changed files with 15 additions and 8 deletions

View File

@ -346,8 +346,7 @@ case class DbGame(
}
def isBeingPlayed =
!finishedOrAborted && updatedAt.fold(
_ > DateTime.now - 20.seconds, false)
!finishedOrAborted && updatedAt.fold(_ > DateTime.now - 20.seconds, false)
def hasBookmarks = bookmarks > 0

View File

@ -13,9 +13,10 @@ import play.api.Play.current
final class MoveNotifier(
siteHubName: String,
lobbyHubName: String,
tournamentHubMasterName: String,
countMove: () Unit) {
lazy val hubRefs = List(siteHubName, lobbyHubName) map { name
lazy val hubRefs = List(siteHubName, lobbyHubName, tournamentHubMasterName) map { name
Akka.system.actorFor("/user/" + name)
}

View File

@ -44,6 +44,7 @@ final class RoundEnv(
lazy val moveNotifier = new MoveNotifier(
siteHubName = ActorSiteHub,
lobbyHubName = ActorLobbyHub,
tournamentHubMasterName = ActorTournamentHubMaster,
countMove = countMove)
lazy val socket = new Socket(

View File

@ -7,7 +7,7 @@ import play.api.templates.Html
trait AssetHelper {
val assetVersion = 84
val assetVersion = 85
def cssTag(name: String) = css("stylesheets/" + name)

View File

@ -1,7 +1,7 @@
package lila
package tournament
import socket.{ History, Broom, Close, GetNbMembers, GetUsernames, NbMembers, SendTo }
import socket.{ History, Broom, Close, GetNbMembers, GetUsernames, NbMembers, SendTo, Fen }
import akka.actor._
import akka.actor.ReceiveTimeout
@ -59,13 +59,15 @@ final class HubMaster(
sender ! Nil
)
case GetTournamentIds => hubs.keys
case GetTournamentIds hubs.keys
case GetUsernames Future.traverse(hubs.values) { hub
(hub ? GetUsernames).mapTo[Iterable[String]]
} map (_.flatten) pipeTo sender
case msg @ NbMembers(_) hubs.values foreach (_ ! msg)
case msg @ Fen(_, _, _) hubs.values foreach (_ ! msg)
}
private def mkHub(tournamentId: String): ActorRef =

View File

@ -14,7 +14,7 @@ import scalaz.effects._
import user.User
import game.DbGame
import socket.{ PingVersion, Quit, Resync }
import socket.{ PingVersion, Quit, Resync, LiveGames }
import socket.Util.connectionFail
import security.Flood
import implicits.RichJs._
@ -77,6 +77,9 @@ final class Socket(
case Some("p") e int "v" foreach { v
hub ! PingVersion(uid, v)
}
case Some("liveGames") e str "d" foreach { ids
hub ! LiveGames(uid, ids.split(' ').toList)
}
case Some("talk") for {
username member.username
data e obj "d"

View File

@ -93,5 +93,4 @@ $(function() {
name: "tournament"
}
}));
$('body').trigger('lichess.content_loaded');
});

2
todo
View File

@ -46,3 +46,5 @@ tournament crowd
tournament monitor
all hub members should use userIds rather than usernames
tournament miniboards are not updating
finish games when tournament is over
tournament players are winning one point just by having a game in progress!