When will onroomlistupdate() be called?

When is the onroomlistupdate() function of PuN2 called? Isn't it called when the room list is updated? But after Deugging, I found that it was only called when I called the JoinLobby () function in the initial Login (). It has not been called when I joined or created a room, then I called LeaveLobby () in LeaveRoom (), and called JoinLobby () again.But it's still not called

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2021
    Hi @Lhiker,

    Thank you for choosing Photon!

    OnRoomListUpdate callback is called in two cases:

    - when client receives GameList event received when joining lobby of type default.
    - when client receives GameListUpdate event when joined to a lobby of type default and one or more rooms inside the lobby change one one of more of its properties visible to the lobby (IsOpen, IsVisible, PlayerCount, MaxPlayers or custom room properties explicitly exposed to the lobby).

    EDIT, UPDATE:

    Ah yes, I forgot one more case:

    OnRoomListUpdate will be called as a result of op GetGameList for SQL Lobbies (PhotonNetwork.GetCustomRoomList)
  • Thanks for the response @JohnTube mod,
    Do you mean to say when I coded PhotonNetwork.CurrentRoom.IsVisible = false; OnRoomListUpdate callback will be called? I think it might be, but there is error,Operation GetGameList (217) not allowed on current server (GameServer)。Can you tell me why?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Ah yes, I forgot one more case:

    OnRoomListUpdate will be called as a result of op GetGameList for SQL Lobbies (PhotonNetwork.GetCustomRoomList)

    PhotonNetwork.GetCustomRoomList can be called only when connected to master server, outside of rooms.
  • Lhiker
    Lhiker
    edited May 2021
    I seem to know what the problem is. When I join or create a room, I will automatically exit the lobby. At this time, I can not update the room list unless I join the lobby again. I always thought that after leaving the room, I was still in the lobby, which led to the error。In the end, thanks for your help again.
  • Lhiker wrote: »
    I seem to know what the problem is. When I join or create a room, I will automatically exit the lobby. At this time, I can not update the room list unless I join the lobby again. I always thought that after leaving the room, I was still in the lobby, which led to the error。In the end, thanks for your help again.
    So, how can I solve this? I stepped on this pit recently, thank you
  • Lhiker
    Lhiker
    edited May 2021
    Have you solved the problem? If not, here is my solution. You can call PhotonNetwork.JoinLobby() in OnConnectedToMaster(). Client will call OnConnectedToMaster after leaving the room, and thus client will join lobby at the same time.
  • I tried implementing this to see if it gives me any correct results for a room that is already created and nothing happens. It almost feels like the callback is not called after GetCustomRoomList() is called.

    And yes, I am in a lobby when the Refresh method is called.

    private void Refresh()
    {
        Debug.Log("Refresh");
        PhotonNetwork.GetCustomRoomList(customLobby, "C0 = 'yes'");
        Debug.Log(PhotonNetwork.InLobby);
    }
    
    
    public override void OnRoomListUpdate(List<RoomInfo> roomList)
    {
        Debug.Log(roomList.Count);
        Rooms = roomList;
        RefreshVisuals();
    }
    

    And this is how the room is created:

    RoomOptions options = new RoomOptions();
    options.MaxPlayers = (byte)nrPlayers_HostGame;
    options.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable()
    {
        { "C0", "yes"},
        { "C1", HG_NameGame.text}
    };
    options.CustomRoomPropertiesForLobby = new string[] { "C0", "C1" };
    

    Can somebody please tell me why this is not working? I've been trying to figure it out since yesterday and I can't seem to find something that's useful. :-(

  • Tobias
    Tobias admin
    edited June 22

    I think you create the room in the default lobby, which in turn does not support GetCustomRoomList and neither the filtering string.

    Make sure to use an SQL lobby (for the room and joining it)...

  • I'm 100% sure I'm not creating the room in a default lobby.

    private TypedLobby customLobby = new TypedLobby("lobby1", LobbyType.SqlLobby);
    
  • Tobias
    Tobias admin
    edited June 23

    Yes, ok, you got the customLobby field. Are you using this in CreateRoom() as parameter?

    As you are so sure you don't miss anything: Please help me help you and create a tiny repro project. Just something I can run, no visual fluff. I don't even need gui, as I could log anything needed. Just something that shows the issue.

    Then, upload the zip for us and send a link to: [email protected]

    Thanks