onRoomListUpdate not updating roomlist properly?

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.

onRoomListUpdate not updating roomlist properly?

Howardxu23
2021-11-02 00:02:18

currently I'm trying to create a server list browser, and it relied on onRoomListUpdate() to get the list of rooms. while it works fine when there is only one room on the lobby at a time, but when it no longer exists or a new room from another player is created.

The former keeps the room there even though it knows it does not exist, and said code should not put it there either. Attempting to join the limbo room yields a onjoinroomfailed,32758, game does not exist) The latter seems to "overwite" the previous room panel, making the rest of the code think that there is only one room. I have noted that it fixes itself every time I disconnect from the server and rejoin it, only then it displays correctly for both issues.

code for the override of onroomlistupdate():

Comments

[Deleted User]
2021-11-02 08:03:50

Don't clear the old room list. This is not how it's supposed to be used. OnRoomListUpdate sends a list of updated rooms. It does not contain every single room in the entire region every time on each send unless you are first joining the lobby, after you get the first dispatch it will only give you updates from then on. RemovedFromList exists because you are supposed to remove it from the list once it's not there anymore.

Howardxu23
2021-11-02 13:03:48

MeepPun 2021-11-02T08:03:50+00:00

Don't clear the old room list. This is not how it's supposed to be used. OnRoomListUpdate sends a list of updated rooms. It does not contain every single room in the entire region every time on each send unless you are first joining the lobby, after you get the first dispatch it will only give you updates from then on. RemovedFromList exists because you are supposed to remove it from the list once it's not there anymore.

public List<RoomInfo> Rooms = new List<RoomInfo>();  
 
public override void OnRoomListUpdate(List<RoomInfo> p_list)  
{  
   base.OnRoomListUpdate(p_list);  
 
   foreach (var room in p_list)  
   {  
       if (room.RemovedFromList)  
       {  
           Rooms.Remove(room);  
           continue;  
       }  
 
       Rooms.Add(room);  
   }  
}  

ah the clearing of the old room list is clearing the display on the game side

Howardxu23
2021-11-02 13:28:50

MeepPun 2021-11-02T08:03:50+00:00

Don't clear the old room list. This is not how it's supposed to be used. OnRoomListUpdate sends a list of updated rooms. It does not contain every single room in the entire region every time on each send unless you are first joining the lobby, after you get the first dispatch it will only give you updates from then on. RemovedFromList exists because you are supposed to remove it from the list once it's not there anymore.

public List<RoomInfo> Rooms = new List<RoomInfo>();  
 
public override void OnRoomListUpdate(List<RoomInfo> p_list)  
{  
   base.OnRoomListUpdate(p_list);  
 
   foreach (var room in p_list)  
   {  
       if (room.RemovedFromList)  
       {  
           Rooms.Remove(room);  
           continue;  
       }  
 
       Rooms.Add(room);  
   }  
}  

the clearlist is to clear the player's GUI server list panel, and does not do anything to the code

Anyway I modified the code, while it seems to have fixed the rooms being created and destroyed, a new issue pops up.

when a player joins/leaves a created room, the code thinks that a new room is created, so creates a duplicate panel of the same room, instead of updating the previous panel data.

if I try to clear the Roomlist each time before the first foreach then the aftermentioned problem sets in again.

Howardxu23
2021-11-02 17:07:53

so do I need to look for the old room's name and update other details in it, say I have a player amount displayed as well, have the code match the room's name and then update the value of it?

Back to top