fix(ws): revert incompatible handshake.query usage
handshake.query(String) does not exist in the current Quarkus WebSocket API version. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user