OnRoomListUpdate limitation for lobbies with many rooms?

Options
Hey there,
I was wondering if it's a good idea to listen for the OnRoomListUpdate event when you are in a lobby with possibly many rooms or will this make the client lag? If so, is there a way I can limit the number of rooms I receive (something like a paging system that returns me only, at example, 20 rooms at a time, and the user can choose to load more) or any way around this problem?

Thanks

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2021
    Options
    Hi @rotolonico,

    Thank you for choosing Photon!
    will this make the client lag?
    Yes it may.

    If you can avoid joining lobbies don't join them to list rooms and join random rooms directly.
    If you can use SQL Lobby (which no longer lists rooms), you could make use of GetGameList to query a selected games based on SQL filter (up to 100).
    If so, is there a way I can limit the number of rooms I receive (something like a paging system that returns me only, at example, 20 rooms at a time, and the user can choose to load more) or any way around this problem?
    Try this modified JoinLobby operation to limit the list of rooms (may not work as expected, experimental):

    This should be added as an extension method (e.g. loadBalancingClient.JoinLobby(lobby, 20, null)):
        using ExitGames.Client.Photon;
        using System.Collections;
        using Photon.Realtime;
    
        public static class ExtensionMethods
        {
         
            public static void JoinLobby(this LoadBalancingClient loadBalancingClient, TypedLobby lobby, int gameCount, Hashtable gamePropertiesFilter)
            {
                ParameterDictionary parameters = new ParameterDictionary();
                if (lobby != null && !lobby.IsDefault)
                {
                    parameters[ParameterCode.LobbyName] = lobby.Name;
                    parameters[ParameterCode.LobbyType] = (byte)lobby.Type;
                }
                if (gameCount > 0) // != 0
                {
                    parameters[ParameterCode.GameCount] = gameCount;
                }
                if (gamePropertiesFilter != null && gamePropertiesFilter.Count > 0)
                {
                    parameters[ParameterCode.GameProperties] = gamePropertiesFilter;
                }
                loadBalancingClient.LoadBalancingPeer.SendOperation(OperationCode.JoinLobby, parameters, SendOptions.SendReliable);
            }
    }