tournament chat
This commit is contained in:
parent
7f16378ae6
commit
d2c1323b04
|
@ -54,20 +54,25 @@ object Tournament extends LilaController {
|
|||
}
|
||||
|
||||
private def showCreated(tour: Created)(implicit ctx: Context) =
|
||||
env version tour.id map { html.tournament.show.created(tour, _) }
|
||||
env.version(tour.id) zip chatOf(tour) map {
|
||||
case (version, chat) ⇒ html.tournament.show.created(tour, version, chat)
|
||||
}
|
||||
|
||||
private def showStarted(tour: Started)(implicit ctx: Context) =
|
||||
env.version(tour.id) zip
|
||||
chatOf(tour) zip
|
||||
GameRepo.games(tour recentGameIds 4) zip
|
||||
tour.userCurrentPov(ctx.me).??(GameRepo.pov) map {
|
||||
case ((version, games), pov) ⇒
|
||||
html.tournament.show.started(tour, version, games, pov)
|
||||
case (((version, chat), games), pov) ⇒
|
||||
html.tournament.show.started(tour, version, chat, games, pov)
|
||||
}
|
||||
|
||||
private def showFinished(tour: Finished)(implicit ctx: Context) =
|
||||
env.version(tour.id) zip GameRepo.games(tour recentGameIds 4) map {
|
||||
case (version, games) ⇒
|
||||
html.tournament.show.finished(tour, version, games)
|
||||
env.version(tour.id) zip
|
||||
chatOf(tour) zip
|
||||
GameRepo.games(tour recentGameIds 4) map {
|
||||
case ((version, chat), games) ⇒
|
||||
html.tournament.show.finished(tour, version, chat, games)
|
||||
}
|
||||
|
||||
def join(id: String) = AuthBody { implicit ctx ⇒
|
||||
|
@ -183,4 +188,7 @@ object Tournament extends LilaController {
|
|||
case (version, uid) ⇒ env.socketHandler.join(id, version, uid, ctx.me)
|
||||
})
|
||||
}
|
||||
|
||||
private def chatOf(tour: lila.tournament.Tournament)(implicit ctx: Context) =
|
||||
ctx.isAuth ?? (Env.chat.api.userChat find tour.id map (_.some))
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
@tournament.show.layout(
|
||||
tour = tour,
|
||||
goodies = tournament.infoBox(tour),
|
||||
chat = None,
|
||||
version = version,
|
||||
title = trans.join.str() + tour.nameT) {
|
||||
@tournament.show.createdInner(tour, formHtml.some)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(title: String, moreJs: Html = Html(""), goodies: Option[Html] = None, underchat: Option[Html] = None)(body: Html)(implicit ctx: Context)
|
||||
@(title: String, moreJs: Html = Html(""), goodies: Option[Html] = None, chat: Option[Html] = None, underchat: Option[Html] = None)(body: Html)(implicit ctx: Context)
|
||||
|
||||
@moreCss = {
|
||||
@cssTag("tournament.css")
|
||||
|
@ -9,6 +9,7 @@ title = title,
|
|||
moreCss = moreCss,
|
||||
moreJs = moreJs,
|
||||
goodies = goodies,
|
||||
chat = chat,
|
||||
active = siteMenu.tournament.some,
|
||||
underchat = underchat) {
|
||||
@body
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
@(tour: lila.tournament.Created, version: Int)(implicit ctx: Context)
|
||||
@(tour: lila.tournament.Created, version: Int, chat: Option[lila.chat.UserChat])(implicit ctx: Context)
|
||||
|
||||
@tournament.show.layout(
|
||||
tour = tour,
|
||||
goodies = tournament.infoBox(tour),
|
||||
chat = chat,
|
||||
version = version,
|
||||
title = tour.nameT) {
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
@(tour: lila.tournament.Finished, version: Int, games: List[Game])(implicit ctx: Context)
|
||||
@(tour: lila.tournament.Finished, version: Int, chat: Option[lila.chat.UserChat], games: List[Game])(implicit ctx: Context)
|
||||
|
||||
@tournament.show.layout(
|
||||
tour = tour,
|
||||
goodies = tournament.infoBox(tour),
|
||||
chat = chat,
|
||||
version = version,
|
||||
side = tournament.pairings(tour).some,
|
||||
title = tour.nameT) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(tour: lila.tournament.Tournament, title: String, version: Int, goodies: Html, side: Option[Html] = None)(body: Html)(implicit ctx: Context)
|
||||
@(tour: lila.tournament.Tournament, chat: Option[lila.chat.UserChat], title: String, version: Int, goodies: Html, side: Option[Html] = None)(body: Html)(implicit ctx: Context)
|
||||
|
||||
@underchat = {
|
||||
<div class="watchers">
|
||||
|
@ -9,6 +9,7 @@
|
|||
@tournament.layout(
|
||||
title = title,
|
||||
goodies = goodies.some,
|
||||
chat = chat.map(c => base.chat(c, trans.chatRoom.str())),
|
||||
underchat = underchat.some) {
|
||||
<div
|
||||
id="tournament"
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
@(tour: lila.tournament.Started, version: Int, games: List[Game], pov: Option[Pov])(implicit ctx: Context)
|
||||
@(tour: lila.tournament.Started, version: Int, chat: Option[lila.chat.UserChat], games: List[Game], pov: Option[Pov])(implicit ctx: Context)
|
||||
|
||||
@tournament.show.layout(
|
||||
tour = tour,
|
||||
goodies = tournament.infoBox(tour),
|
||||
chat = chat,
|
||||
version = version,
|
||||
side = tournament.pairings(tour).some,
|
||||
title = tour.nameT) {
|
||||
|
|
|
@ -12,7 +12,7 @@ trait Historical[M <: SocketMember] { self: SocketActor[M] ⇒
|
|||
}
|
||||
|
||||
def sendMessage(message: History.Message)(member: M) {
|
||||
if (!message.troll || member.troll) member.channel push message.msg
|
||||
if (!message.troll || member.troll) member.channel push message.msg.pp
|
||||
}
|
||||
def sendMessage(member: M)(message: History.Message) {
|
||||
sendMessage(message)(member)
|
||||
|
|
|
@ -47,6 +47,7 @@ final class Env(
|
|||
lazy val socketHandler = new SocketHandler(
|
||||
hub = hub,
|
||||
socketHub = socketHub,
|
||||
chat = hub.actor.chat,
|
||||
flood = flood)
|
||||
|
||||
private lazy val history = () ⇒ new History(ttl = MessageTtl)
|
||||
|
|
|
@ -7,10 +7,10 @@ import play.api.libs.iteratee._
|
|||
import play.api.libs.json._
|
||||
|
||||
import actorApi._
|
||||
import lila.hub.TimeBomb
|
||||
import lila.memo.ExpireSetMemo
|
||||
import lila.socket.actorApi.{ Connected ⇒ _, _ }
|
||||
import lila.socket.{ SocketActor, History, Historical }
|
||||
import lila.hub.TimeBomb
|
||||
|
||||
private[tournament] final class Socket(
|
||||
tournamentId: String,
|
||||
|
@ -54,6 +54,12 @@ private[tournament] final class Socket(
|
|||
if (timeBomb.boom) self ! PoisonPill
|
||||
}
|
||||
|
||||
case lila.chat.actorApi.ChatLine(_, line) ⇒ line match {
|
||||
case line: lila.chat.UserLine ⇒
|
||||
notifyVersionTrollable("message", lila.chat.Line toJson line, troll = line.troll)
|
||||
case _ ⇒
|
||||
}
|
||||
|
||||
case GetVersion ⇒ sender ! history.version
|
||||
|
||||
case Join(uid, user, version) ⇒ {
|
||||
|
|
|
@ -13,6 +13,7 @@ import lila.db.api.$count
|
|||
import lila.game.Game
|
||||
import lila.hub.actorApi.map._
|
||||
import lila.security.Flood
|
||||
import akka.actor.ActorSelection
|
||||
import lila.socket.actorApi.{ Connected ⇒ _, _ }
|
||||
import lila.socket.Handler
|
||||
import lila.user.User
|
||||
|
@ -22,6 +23,7 @@ import tube.tournamentTube
|
|||
private[tournament] final class SocketHandler(
|
||||
hub: lila.hub.Env,
|
||||
socketHub: ActorRef,
|
||||
chat: ActorSelection,
|
||||
flood: Flood) {
|
||||
|
||||
def join(
|
||||
|
@ -54,10 +56,10 @@ private[tournament] final class SocketHandler(
|
|||
case ("liveGames", o) ⇒ o str "d" foreach { ids ⇒
|
||||
socket ! LiveGames(uid, ids.split(' ').toList)
|
||||
}
|
||||
case ("talk", o) ⇒ for {
|
||||
t ← o str "d"
|
||||
userId ← member.userId
|
||||
if flood.allowMessage(uid, t)
|
||||
} socket ! Talk(tourId, userId, t, member.troll)
|
||||
case ("talk", o) ⇒ o str "d" foreach { text ⇒
|
||||
member.userId foreach { userId ⇒
|
||||
chat ! lila.chat.actorApi.UserTalk(tourId, userId, text, socket)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,8 @@ object ApplicationBuild extends Build {
|
|||
libraryDependencies ++= provided(play.api, RM, PRM)
|
||||
)
|
||||
|
||||
lazy val tournament = project("tournament", Seq(common, hub, socket, chess, game, round, setup, security)).settings(
|
||||
lazy val tournament = project("tournament", Seq(
|
||||
common, hub, socket, chess, game, round, setup, security, chat)).settings(
|
||||
libraryDependencies ++= provided(play.api, RM, PRM)
|
||||
)
|
||||
|
||||
|
|
|
@ -349,9 +349,7 @@ var storage = {
|
|||
}
|
||||
},
|
||||
message: function(msg) {
|
||||
$('div.lichess_chat').each(function() {
|
||||
$(this).chat("append", msg);
|
||||
});
|
||||
$('div.lichess_chat').chat("append", msg);
|
||||
},
|
||||
nbm: function(e) {
|
||||
$('#nb_messages').text(e || "0").toggleClass("unread", e > 0);
|
||||
|
@ -2468,6 +2466,11 @@ var storage = {
|
|||
var socketUrl = $wrap.data("socket-url");
|
||||
var $watchers = $("div.watchers").watchers();
|
||||
|
||||
var $chat = $("div.lichess_chat").chat({
|
||||
resize: true,
|
||||
messages: lichess_chat
|
||||
});
|
||||
|
||||
function startClock() {
|
||||
$("span.tournament_clock").each(function() {
|
||||
$(this).clock({
|
||||
|
|
Loading…
Reference in a new issue