I want to update a room list.

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

I want to update a room list.

Lim
2022-08-10 07:02:23

Hello Guys,

A room list needs to update without creating or removing a room for OnRoomListUpdate callback, well do you have any idea for it?

In someone's question and answers, I've found there's no way the update with a method like refresh button due to that the game can be busy.

However, a player can't see any room if the change is intermittently.

And I don't get how to use GetCustomRoomList with sqlLobbyFilter.

Thanks for reading.

Comments

Lim
2022-08-10 07:33:14

Below, it works with GetCustomRoomList, but OnRoomListUpdate is not working.

It's for update a room list when someone start a scene right then.

private TypedLobby m_lobby;    
      
  void Start()    
  {            
    m_lobby = new TypedLobby("def", LobbyType.SqlLobby);    
    PhotonNetwork.GetCustomRoomList(m_lobby, "C0 = '1'");    
  }    

public void CreateRoom()    
  {    
    if (isCreating) return;    


    Debug.Log("CreateRoom");    
    isCreating = true;    
    RoomOptions ro = new RoomOptions();    
    ro.IsOpen = true;    
    ro.IsVisible = true;    
    ro.MaxPlayers = 4;    
    ro.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "C0", "1" } };    
    ro.CustomRoomPropertiesForLobby = new string[] { "C0" };    

    if (string.IsNullOrEmpty(m_nickNameInput.text))    
    {    
      m_nickNameInput.text = $"BABO_{Random.Range(1, 100):000}";    
    }    
    if (string.IsNullOrEmpty(m_roomNameInput.text))    
    {    
      m_roomNameInput.text = $"ROOM_{Random.Range(1, 100):000}";    
    }    

    PhotonNetwork.NickName = m_nickNameInput.text;    
    PhotonNetwork.CreateRoom(m_roomNameInput.text, ro, m_lobby);    
  }    

Tobias
2022-08-10 14:59:32

I don't understand what is needed, sorry.

When you join a lobby, you get a room list and updates for it. This actually means you need to keep the initial list and update it. This means your code is control of knowing the complete list anytime you are in a lobby and you can use that to update any view of it.

The lobby's list is pushed to the clients and there is no way to ask for it (unless you use SQL lobbies, which don't send the updates but you can ask it to find a random room with more precise filtering or ask for a custom list).

Back to top