I am currently trying to make a Lobby Menu where i display all the open lobbies, but everytime i start my game the Unity Editor freezes.
I don't get any Errors, Warnings, etc. and i can't open/close my UnityEditor anymore. I have to manually close it in the Task Manager
When i debug my Code, it happens to freeze at this line:
LobbyManager.cs
QueryResponse queryResponse = await Lobbies.Instance.QueryLobbiesAsync(OptionsFactory.QueryLobbiesOptions());
The queryLobbyOptions cannot be the problem, since it freezes without them too.
Optionsfactory.cs
public static QueryLobbiesOptions QueryLobbiesOptions()
{
QueryLobbiesOptions queryLobbiesOptions = new QueryLobbiesOptions
{
Count = 10,
Filters = new List<QueryFilter>
{
new QueryFilter(QueryFilter.FieldOptions.AvailableSlots, "0", QueryFilter.OpOptions.GT)
},
Order = new List<QueryOrder>
{
new QueryOrder(false, QueryOrder.FieldOptions.Created)
}
};
return queryLobbiesOptions;
}
I even tried to query for the lobbies like this:
LobbyManager.cs
List<Lobby> lobbyList = (await Lobbies.Instance.QueryLobbiesAsync(OptionsFactory.QueryLobbiesOptions())).Results;
foreach (var lobby in lobbyList)
{
Debug.Log(lobby.Name);
}
but that won't work either.
Anyone have the same issue or an idea how to fix this issue?
Please do not hesitate and reply if you need more information and details.
@msaiduraz Is it possible to share the
QueryLobbyAsync()
function?
The QueryLobbyAsync()
function is not self-written. It's part of Unity.
The function looks like this:
WrappedLobbyService.cs
/// <inheritdoc/>
public async Task<QueryResponse> QueryLobbiesAsync(QueryLobbiesOptions options = default)
{
var queryRequest = options == null ? null : new QueryRequest(options.Count, options.Skip, options.SampleResults, options.Filters, options.Order, options.ContinuationToken);
var queryLobbiesRequest = new QueryLobbiesRequest(queryRequest);
var response = await TryCatchRequest(m_LobbyService.LobbyApi.QueryLobbiesAsync, queryLobbiesRequest);
return response.Result;
}
Here is the unity documentation for the ILobbyService
@Nikolai In what place do you call QueryLobbiesAsync?
I call this function in my LobbyManager.cs script:
public async Task<List<Lobby>> ListLobbies()
{
try
{
// shutdown
QueryResponse queryResponse = await Lobbies.Instance.QueryLobbiesAsync(OptionsFactory.QueryLobbiesOptions());
List<Lobby> lobbyList = (await Lobbies.Instance.QueryLobbiesAsync(OptionsFactory.QueryLobbiesOptions())).Results;
foreach (var lobby in lobbyList)
{
Debug.Log(lobby.Name);
}
catch (LobbyServiceException e)
{
Debug.Log(e);
return null;
}
return null;
}
> ListLobbies() function (see edit)
– Dru.Dru Apr 05 '23 at 09:27