feat: NCS-82 add Swiss-system tournament module #55

Merged
lq64 merged 11 commits from feat/NCS-82 into main 2026-06-09 15:09:53 +02:00
2 changed files with 2 additions and 9 deletions
Showing only changes of commit c76a7247ba - Show all commits
@@ -96,8 +96,6 @@ class GameWebSocketResource:
private def resolvePlayerId(handshake: HandshakeRequest): Option[String] =
Option(handshake.header("Authorization"))
.filter(_.nonEmpty)
.map(h => if h.startsWith("Bearer ") then h.drop(7) else h)
.orElse(Option(handshake.query("token")).filter(_.nonEmpty))
.flatMap(token => Try(jwtParser.parse(token)).toOption)
.map(_.getSubject)
@@ -35,7 +35,8 @@ class UserWebSocketResource:
@OnOpen
def onOpen(connection: WebSocketConnection, handshake: HandshakeRequest): Unit =
val userIdOpt = resolveToken(handshake)
val userIdOpt = Option(handshake.header("Authorization"))
.filter(_.nonEmpty)
.flatMap(token => Try(jwtParser.parse(token)).toOption)
.map(_.getSubject)
@@ -51,12 +52,6 @@ class UserWebSocketResource:
val connectedMsg = s"""{"type":"CONNECTED","userId":"$userId"}"""
connection.sendText(connectedMsg).subscribe().`with`(_ => (), _ => ())
private def resolveToken(handshake: HandshakeRequest): Option[String] =
Option(handshake.header("Authorization"))
.filter(_.nonEmpty)
.map(h => if h.startsWith("Bearer ") then h.drop(7) else h)
.orElse(Option(handshake.query("token")).filter(_.nonEmpty))
@OnClose
def onClose(connection: WebSocketConnection): Unit =
log.infof("User WebSocket closed — connectionId=%s", connection.id())