Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Sri and Lobby.pong #608

Merged
merged 2 commits into from
Oct 12, 2024
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
2 changes: 1 addition & 1 deletion src/main/scala/Controller.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ final class Controller(
)

def api(header: RequestHeader) =
val req = Req(header, Sri.random, None).copy(flag = Some(Flag.api))
val req = Req(header, Sri.random(), None).copy(flag = Some(Flag.api))
Future.successful(
endpoint(
name = "api",
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/LilaWs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class LilaWsServer(
Bus.publish(_.all, ipc.ClientCtrl.Broom(nowSeconds - 30))

scheduler.scheduleWithFixedDelay(4.seconds, 1201.millis): () =>
val counters = lobby.pong.get
val counters = lobby.pong.get()
lila.emit.lobby(ipc.LilaIn.Counters(counters.members, counters.rounds))

scheduler.scheduleWithFixedDelay(1.seconds, 1879.millis): () =>
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/Lobby.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class Lobby(lila: Lila, groupedWithin: util.GroupedWithin):

private var value = LobbyPong(0, 0)

def get = value
def get() = value

def update(members: Int, rounds: Int): Unit =
value = LobbyPong(members, rounds)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/actor/LobbyClientActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object LobbyClientActor:
case Some(s) => apply(state.copy(site = s), deps)

case msg: ClientOut.Ping =>
clientIn(services.lobby.pong.get)
clientIn(services.lobby.pong.get())
apply(state.copy(site = sitePing(state.site, deps, msg)), deps)

case ClientOut.LobbyJoin(payload) =>
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ object Racer:

opaque type Sri = String
object Sri extends OpaqueString[Sri]:
def random = Sri(SecureRandom.nextString(12))
def from(str: String): Option[Sri] = if str contains ' ' then None else Some(str)
def random() = Sri(SecureRandom.nextString(12))
def from(str: String): Option[Sri] = Option.unless(str.contains(' '))(str)

opaque type Flag = String
object Flag extends OpaqueString[Flag]:
Expand Down
Loading