permanent TV chat
This commit is contained in:
parent
eb2ad2c832
commit
7705b8dd95
|
@ -14,7 +14,7 @@ object Tv extends LilaController {
|
||||||
def index = Open { implicit ctx ⇒
|
def index = Open { implicit ctx ⇒
|
||||||
OptionFuResult(Env.game.featured.one) { game ⇒
|
OptionFuResult(Env.game.featured.one) { game ⇒
|
||||||
Env.round.version(game.id) zip
|
Env.round.version(game.id) zip
|
||||||
(WatcherRoomRepo room game.id map { room ⇒
|
(WatcherRoomRepo room "tv" map { room ⇒
|
||||||
html.round.watcherRoomInner(room.decodedMessages)
|
html.round.watcherRoomInner(room.decodedMessages)
|
||||||
}) zip
|
}) zip
|
||||||
(GameRepo onTv 10) zip
|
(GameRepo onTv 10) zip
|
||||||
|
|
|
@ -8,10 +8,16 @@
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@room = {
|
||||||
|
@base.chatRoom(
|
||||||
|
title = "TV " + trans.spectatorRoom.str(),
|
||||||
|
cssClass = "spectators")(roomHtml)
|
||||||
|
}
|
||||||
|
|
||||||
@round.layout(
|
@round.layout(
|
||||||
title = title,
|
title = title,
|
||||||
goodies = views.html.game.infoBox(pov, tour),
|
goodies = views.html.game.infoBox(pov, tour),
|
||||||
chat = round.room(roomHtml, true).some,
|
chat = room.some,
|
||||||
underchat = underchat.some,
|
underchat = underchat.some,
|
||||||
active = siteMenu.tv.some) {
|
active = siteMenu.tv.some) {
|
||||||
@round.watcherGame(pov)
|
@round.watcherGame(pov)
|
||||||
|
|
|
@ -52,14 +52,14 @@ final class Messenger(
|
||||||
}
|
}
|
||||||
|
|
||||||
def watcherMessage(
|
def watcherMessage(
|
||||||
gameId: String,
|
roomId: String,
|
||||||
userId: Option[String],
|
userId: Option[String],
|
||||||
text: String,
|
text: String,
|
||||||
troll: Boolean): Fu[List[Event.WatcherMessage]] = for {
|
troll: Boolean): Fu[List[Event.WatcherMessage]] = for {
|
||||||
userOption ← userId.??(UserRepo.byId)
|
userOption ← userId.??(UserRepo.byId)
|
||||||
message ← userOrAnonMessage(userOption, text).future
|
message ← userOrAnonMessage(userOption, text).future
|
||||||
(u, t) = message
|
(u, t) = message
|
||||||
_ ← !troll ?? WatcherRoomRepo.addMessage(gameId, u, t)
|
_ ← !troll ?? WatcherRoomRepo.addMessage(roomId, u, t)
|
||||||
} yield Event.WatcherMessage(u, t, troll) :: Nil
|
} yield Event.WatcherMessage(u, t, troll) :: Nil
|
||||||
|
|
||||||
def systemMessages(game: Game, messages: List[SelectI18nKey]): Fu[List[Event]] =
|
def systemMessages(game: Game, messages: List[SelectI18nKey]): Fu[List[Event]] =
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package lila.round
|
package lila.round
|
||||||
|
|
||||||
|
import actorApi._, round._
|
||||||
import akka.actor._
|
import akka.actor._
|
||||||
import akka.pattern.{ ask, pipe }
|
import akka.pattern.{ ask, pipe }
|
||||||
|
import chess.Color
|
||||||
|
import makeTimeout.short
|
||||||
import play.api.libs.json.{ JsObject, Json }
|
import play.api.libs.json.{ JsObject, Json }
|
||||||
|
|
||||||
import actorApi._, round._
|
|
||||||
import chess.Color
|
|
||||||
import lila.common.PimpedJson._
|
import lila.common.PimpedJson._
|
||||||
import lila.game.{ Game, Pov, PovRef, PlayerRef, GameRepo }
|
import lila.game.{ Game, Pov, PovRef, PlayerRef, GameRepo }
|
||||||
import lila.hub.actorApi.map._
|
import lila.hub.actorApi.map._
|
||||||
|
@ -13,7 +14,6 @@ import lila.security.Flood
|
||||||
import lila.socket.actorApi.{ Connected ⇒ _, _ }
|
import lila.socket.actorApi.{ Connected ⇒ _, _ }
|
||||||
import lila.socket.Handler
|
import lila.socket.Handler
|
||||||
import lila.user.{ User, Context }
|
import lila.user.{ User, Context }
|
||||||
import makeTimeout.short
|
|
||||||
|
|
||||||
private[round] final class SocketHandler(
|
private[round] final class SocketHandler(
|
||||||
roundMap: ActorRef,
|
roundMap: ActorRef,
|
||||||
|
@ -34,16 +34,17 @@ private[round] final class SocketHandler(
|
||||||
roundMap ! Tell(gameId, msg)
|
roundMap ! Tell(gameId, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
member.playerIdOption.fold[Handler.Controller]({
|
def watcherTalk(roomId: String, o: JsObject) {
|
||||||
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
for {
|
||||||
case ("talk", o) ⇒ for {
|
|
||||||
txt ← o str "d"
|
txt ← o str "d"
|
||||||
if flood.allowMessage(uid, txt)
|
if flood.allowMessage(uid, txt)
|
||||||
} messenger.watcherMessage(
|
} messenger.watcherMessage(roomId, member.userId, txt, member.troll) pipeTo socket
|
||||||
ref.gameId,
|
}
|
||||||
member.userId,
|
|
||||||
txt,
|
member.playerIdOption.fold[Handler.Controller]({
|
||||||
member.troll) pipeTo socket
|
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
||||||
|
case ("talk", o) ⇒ watcherTalk(ref.gameId, o)
|
||||||
|
case ("talk-tv", o) ⇒ watcherTalk("tv", o)
|
||||||
}) { playerId ⇒
|
}) { playerId ⇒
|
||||||
{
|
{
|
||||||
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
case ("p", o) ⇒ o int "v" foreach { v ⇒ socket ! PingVersion(uid, v) }
|
||||||
|
|
|
@ -800,6 +800,7 @@ var storage = {
|
||||||
self.initTable();
|
self.initTable();
|
||||||
self.initClocks();
|
self.initClocks();
|
||||||
if (self.$chat) self.$chat.chat({
|
if (self.$chat) self.$chat.chat({
|
||||||
|
talkMessageType: self.options.tv ? 'talk-tv' : 'talk',
|
||||||
resize: true,
|
resize: true,
|
||||||
render: function(u, t) {
|
render: function(u, t) {
|
||||||
if (self.options.player.spectator) {
|
if (self.options.player.spectator) {
|
||||||
|
@ -1497,6 +1498,7 @@ var storage = {
|
||||||
this.options = $.extend({
|
this.options = $.extend({
|
||||||
// render: function(u, t) {},
|
// render: function(u, t) {},
|
||||||
onToggle: function(enabled) {},
|
onToggle: function(enabled) {},
|
||||||
|
talkMessageType: 'talk',
|
||||||
resize: false
|
resize: false
|
||||||
}, this.options);
|
}, this.options);
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -1519,7 +1521,7 @@ var storage = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$input.val('');
|
$input.val('');
|
||||||
lichess.socket.send('talk', text);
|
lichess.socket.send(self.options.talkMessageType, text);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue