Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/scala/LilaHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ final class LilaHandler(
)
case ApiUserOnline(user, false) => users.tellOne(user, ClientCtrl.ApiDisconnect)

case Impersonate(user, by) => Impersonations(user, by)
case StreamersOnline(streamers: Iterable[(User.Id, String)]) => Streamer.set(streamers)
case Pong(pingAt) => Monitor.ping.record("site", pingAt)
case Impersonate(user, by) => Impersonations(user, by)
case StreamersOnline(streamers) => Streamer.set(streamers)
case Pong(pingAt) => Monitor.ping.record("site", pingAt)

case LilaStop(reqId) =>
logger.info("******************** LILA STOP ********************")
Expand Down
8 changes: 5 additions & 3 deletions src/main/scala/Streamer.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package lila.ws

import play.api.libs.json.JsValue

// this set comes from lila/modules/streamer and is updated a few times per minute at most
object Streamer:
@volatile private var streams = Map.empty[User.Id, String]
@volatile private var streams = Map.empty[User.Id, JsValue]

def set(newStreams: Iterable[(User.Id, String)]): Unit =
def set(newStreams: Iterable[(User.Id, JsValue)]): Unit =
streams = newStreams.toMap

def intersect(userIds: Iterable[User.Id]): Map[User.Id, String] =
def intersect(userIds: Iterable[User.Id]): Map[User.Id, JsValue] =
streams.view.filterKeys(userIds.toSet).toMap
10 changes: 3 additions & 7 deletions src/main/scala/ipc/LilaOut.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lila.ws
package ipc

import chess.Color
import play.api.libs.json.*

sealed trait LilaOut

Expand Down Expand Up @@ -32,7 +33,7 @@ object LilaOut:
case class UnFollow(left: User.Id, right: User.Id) extends SiteOut
case class Pong(pingAt: UptimeMillis) extends SiteOut with RoundOut
case class LilaResponse(reqId: Int, body: String) extends SiteOut with RoundOut
case class StreamersOnline(streamers: Iterable[(User.Id, String)]) extends SiteOut
case class StreamersOnline(streamers: Map[User.Id, JsValue]) extends SiteOut

// lobby

Expand Down Expand Up @@ -327,12 +328,7 @@ object LilaOut:
Some(ApiUserOnline(User.Id(userId), boolean(online)))
}

case "streamers/online" =>
Some(StreamersOnline {
commas(args)
.map(_.split(':'))
.collect { case Array(userId, name) => (User.Id(userId), name) }
})
case "streamers/online" => Json.parse(args).asOpt[Map[User.Id, JsValue]].map(StreamersOnline.apply)

case "pong" => args.toLongOption.map(UptimeMillis.apply).map(Pong.apply)

Expand Down