OnRoomListUpdate returns rooms that have been closed when master client closes game (PUN2)

Hi,

I've been going through the forums looking for someone that has faced a similar situation as I am now, but I couldn't find anything. Sorry if there has been.

I'm using PUN2 and OnRoomListUpdate() to get available rooms for the client, I am caching these results.

1.Whenever a new room pops up there is no issue, and is shown in game.

2. However, when one of the master clients of the room decides to close the game (either from Alt + F4 or just by closing the window). OnRoomListUpdate() will be called at that instance for other clients in Lobby, but the roomList it returns will still return the closed room as open.

3. I'm having difficulty removing it from my cached list as OnRoomListUpdate is not called again unless a new room is opened or the client exits the lobby and join again. Only then does it show that the room has been closed and I can remove it.

What should I do?

Thanks in advance for anyone that can help me :)

Comments

  • Oh I forgot to mention but I am more than happy to post my code if it will help with debugging. Thanks!
  • S_OliverS_Oliver ✭✭
    edited February 3
    Hello, i was working on a Room Overview and have to say it works like it should.

    Please post your Code.

    Here a snippet
    https://pastebin.com/R9hsVrFu
  • Hey, I've been going through your code and it looks fine to me. But for some reason my roomlist doesn't show any rooms that have been removed from list.

    I've attached my code that is responsible for this purpose
    https://pastebin.com/tEawH06F
  • Hey @S_Oliver,

    I would also refresh the info/UI of the rooms already cached in the list.
                if (m_roomPanelList.ContainsKey(entry.Name))
                {
                   
                    if (entry.RemovedFromList)
                    {
                        RemoveRoomPanel(entry);
                    } 
                    else 
                    {
                        RefreshRoomPanel(entry);
                    }
  • Hey @JohnTube ,

    the RoomPanels refresh on it self, but thanks.

    @Hurbivore
    It seems you overcomplicating things in your script.
    Take a look in the Demo or just look closer at the snippet i posted.
    OnRoomListUpdate wors like expected.
  • JohnTubeJohnTube mod
    edited February 5
    Hi @S_Oliver,

    the RoomPanels refresh on it self
    I don't think so. The new updated RoomInfo is never passed to the RoomPanels so it can't get the new values. OnRoomListUpdate sends you updates whenever RoomInfo values of existing/old rooms change. You need to use those new RoomInfo to override old ones. Examples: room is closed, players count change, etc. You can't get that from elsewhere other than OnRoomListUpdate.
  • S_OliverS_Oliver ✭✭
    edited February 5
    @JohnTube

    Well, i only posted a snippet, so my fault, you didnt saw the full code, but trust me the Panels getting refreshed : )
  • Hey @S_oliver,
    I know I'm over complicating things right now but regardless during my OnRoomListUpdate as I'm iterating through roomInfo the room's status is being printed into the log. However, "Room has been removed from list", is never called.
  • Change the if else statement in OnRoomListUpdate toif (room.RemovedFromList == false) { Debug.Log("room is open"); } else { Debug.Log("Room has been removed from list"); }
  • Thanks that worked!
Sign In or Register to comment.