Get rooms list (PUN 2)

Hello,
I have a question - how can I get a list of rooms in lobby? I see that after joining the lobby i can get rooms with overriding OnRoomListUpdate, it works great just after joining the lobby, I mean once.
After that for example if I change the room isVisible to 'false' it is also called but in this RoomInfo this isVisible property is still set to 'true'.
Another scenario is with 2 rooms, for example:
1. I'm running the client and I join lobby
2. On other instance of the game I create a room.
3. On this client from point 1 I get in this OnRoomListUpdate info about created room.
4. I start another instance of the game and create second room
5. On this client from point 1 I get in this OnRoomListUpdate info about created room, but there is no info about the previous one (there is only the room from point 4, but if i restart this client from point 1 and join lobby I get full list with 2 rooms)

So how should I get those rooms list, so I have full list of rooms with actual properties like isVisible, isOpen?

I'm using PUN 2 Free version and Unity 2018.2.6f1

Answers

  • Hi @asdf,

    in PUN 2 we don't cache the room list any longer, this has to be done by yourself. This is the reason, why you see the behaviour mentioned in the 5th point. To see how caching the room list works, you can take a look at the Asteroids demo from the PUN package. You need to have at least version 2.01 because it has been added with this version.

    In this demo, you can have a look at the LobbyMainPanel class which caches the room list locally. Important for this caching is the OnRoomListUpdate callback and the UpdateCachedRoomList function, which actually updates the local cache.
  • Ok I see, anyway what about this IsVisible, IsOpen? Why after I change this properties I don't get OnRoomListUpdate with correct data for this room - this method is rised on other clients but I still see there IsVisible = 'true'
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @asdf,

    Thank you for choosing Photon!

    You should get updates when a room in the lobby when IsVisible or IsOpen values are changed.
    but I still see there IsVisible = 'true'

    what about RoomInfo.RemovedFromList?