Skip to content

Commit

Permalink
Merge pull request #608 from lenguyenthanh/improve-sri
Browse files Browse the repository at this point in the history
Improve Sri and Lobby.pong
  • Loading branch information
ornicar authored Oct 12, 2024
2 parents b7a58ac + 9771ea3 commit 6ed2684
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/Controller.scala
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,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 @@ -64,7 +64,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

0 comments on commit 6ed2684

Please sign in to comment.