feat(api): BAC-10 Websockets - Kick Users (#93)

Reviewed-on: #93
Co-authored-by: Janis <janis.e.20@gmx.de>
Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
2025-12-01 19:50:19 +01:00
committed by Janis
parent 89a6aa22f7
commit 0541bb58d1
4 changed files with 14 additions and 3 deletions

View File

@@ -64,6 +64,15 @@ class UserSession(val user: User, val host: Boolean, val gameLobby: GameLobby) e
case None =>
println("Card Index not found or is not a number.")
}
case "KickPlayer" =>
val maybePlayerId: Option[String] = (data \ "playerId").asOpt[String]
maybePlayerId match {
case Some(id) =>
val playerUUID = UUID.fromString(id)
gameLobby.leaveGame(playerUUID, true)
case None =>
println("Player ID not found or is not a valid UUID.")
}
}
}
lock.unlock()

View File

@@ -60,7 +60,7 @@
<a href="#" class="btn btn-danger disabled" aria-disabled="true" tabindex="-1">Remove</a>
} else {
<h5 class="card-title">@playersession.name</h5>
<div class="btn btn-danger" onclick="removePlayer('@gamelobby.id', '@playersession.id')">
<div class="btn btn-danger" onclick="handleKickPlayer('@playersession.id')">
Remove</div>
}
</div>

View File

@@ -227,7 +227,7 @@ function receiveLobbyUpdateEvent(eventData) {
const inner = user.self ? `<h5 class="card-title">${user.name} (You)</h5>
<a href="#" class="btn btn-danger disabled" aria-disabled="true" tabindex="-1">Remove</a>`
: ` <h5 class="card-title">${user.name}</h5>
<div class="btn btn-danger" onclick="removePlayer('${user.id}')">Remove</div>`
<div class="btn btn-danger" onclick="handleKickPlayer('${user.id}')">Remove</div>`
newHtml += `<div class="col-auto my-auto m-3">
<div class="card" style="width: 18rem;">

View File

@@ -73,5 +73,7 @@ function handleTrumpSelection(object) {
}
function handleKickPlayer(playerId) {
// TODO needs implementation
sendEvent("KickPlayer", {
playerId: playerId
})
}