public async Task LeaveLobby(string reason) { if (!(Context.User.Identity is ClaimsIdentity identity)) { return; } var playerId = identity.FindFirst(JwtService.PlayerIdClaim).Value; var lobbyCode = identity.FindFirst(JwtService.LobbyCodeClaim).Value; if (string.IsNullOrWhiteSpace(playerId) || !Guid.TryParse(playerId, out var playerGuid) || string.IsNullOrWhiteSpace(lobbyCode)) { return; } var player = _lobbyHandler.DisconnectFromLobby(playerGuid, lobbyCode); await Clients.Groups(lobbyCode).SendAsync("LeaveLobbyNotify", player.Username, reason); }