Hello. How can I prevent a player to join a lobby if their Application.version is different than from the Host? Is there a callback for that? I couldn’t find anything in the documentation.
Okay I found a solution for this by using CreateLobbyOptions.
When the host is creating a lobby, it is using this option:
var options = new CreateLobbyOptions
{
Data = new Dictionary<string, DataObject>
{
... your options ...
{
"version", new DataObject(DataObject.VisibilityOptions.Public, Application.version)
},
... your options ...
}
};
currentLobby = await Lobbies.Instance.CreateLobbyAsync(data.name, data.maxPlayers, options);
When a client is joinging a lobby, I added this check:
var lobbyToJoin = await Lobbies.Instance.GetLobbyAsync(lobbyId);
if (!string.Equals(lobbyToJoin.Data["version"].Value, Application.version))
{
throw new Exception("Lobby version mismatch");
}
But I have another question now. How can I do this for joining with lobby code? GetLobbyAsync seems to work only for the lobby id. And it seems like there isnt a function to retrieve the lobby with the lobby code. Only join with code.
I think that the only way is to quickly leave the lobby if there is a version mismatch
1 Like