Custom properties removed after the master client leaves the room? (PUN 2.12)

Options
Hello,

I've had a problem for months related to custom room properties. I have a couple properties that are set to be listed in the lobby, but after the master client leaves the room, it seems they are deleted (they do not show up in the RoomInfo of the room list sent by the lobby).

Here's how I create the room:

		const string ROOM_PROPERTY_GAMEMODE = "g";
		const string ROOM_PROPERTY_PLATFORM = "p";

		RoomOptions roomOptions = new RoomOptions();
		roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();
		roomOptions.CustomRoomProperties.Add(ROOM_PROPERTY_GAMEMODE, gameMode);
		roomOptions.CustomRoomProperties.Add(ROOM_PROPERTY_PLATFORM, platform);
		roomOptions.CustomRoomPropertiesForLobby = new string[] { ROOM_PROPERTY_GAMEMODE, ROOM_PROPERTY_PLATFORM };
		roomOptions.IsOpen = true;
		roomOptions.IsVisible = true;
		roomOptions.MaxPlayers = 8;
		roomOptions.PlayerTtl = 0;
		roomOptions.SuppressRoomEvents = false;
		roomOptions.CleanupCacheOnLeave = false;
		PhotonNetwork.CreateRoom("test", roomOptions))
(gameMode and platform are both enums.)

And when parsing the RoomInfo list in OnRoomListUpdate(), I check:

if (!photonRoomInfo.CustomProperties.ContainsKey(ROOM_PROPERTY_GAMEMODE))
{
	// error...
}
Is this a bug in PUN or do I need to do something differently?
I'm using PUN 2.12.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2019
    Options
    Hi @olistan,

    Room properties are not affected by clients (master nor not) leaving or joining the room.

    they do not show up in the RoomInfo of the room list sent by the lobby
    It's a misunderstanding from your part. When a player leaves, the master server sends you a new room entry with only PlayerCount changed since other room info remain intact/the same.
  • olistan
    Options
    JohnTube said:

    It's a misunderstanding from your part. When a player leaves, the master server sends you a new room entry with only PlayerCount changed since other room info remain intact/the same.

    Oh, so you mean that the room list received in OnRoomListUpdated() contains only the changes?
    Ok, that makes sense (but wasn't obvious from reading the docs).

    If I look at the Asteroids demo, it does:
    
            private void UpdateCachedRoomList(List<RoomInfo> roomList)
            {
                foreach (RoomInfo info in roomList)
                {
                    // Remove room from cached room list if it got closed, became invisible or was marked as removed
                    if (!info.IsOpen || !info.IsVisible || info.RemovedFromList)
                    {
                        if (cachedRoomList.ContainsKey(info.Name))
                        {
                            cachedRoomList.Remove(info.Name);
                        }
    
                        continue;
                    }
    
                    // Update cached room info
                    if (cachedRoomList.ContainsKey(info.Name))
                    {
                        cachedRoomList[info.Name] = info;
                    }
                    // Add new room info to cache
                    else
                    {
                        cachedRoomList.Add(info.Name, info);
                    }
                }
            }
    
    I cannot do the same or I would lose the locally cached room properties at this line:
    
                        cachedRoomList[info.Name] = info;
    
    I'm not sure how to deal with this since I cannot use SetCustomProperties() on a RoomInfo (so I cannot backup the properties, then put them back in the new RoomInfo).

    Alternatively I could copy all the values I'm interested in into my own Room structure I suppose.

    Do you have a suggestion? How is it intended to be done?
    Thanks!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @olistan,

    Please ignore my previous comment. It's wrong.
    We should send complete room info in the event.
    I'm investigating this.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2019
    Options
    Hi @olistan,

    Double check your code.
    I have tested this and it works as expected.

    When a player leaves the room, there are three cases of GameListUpdate/GameList events sent inside the lobby:

    1. The room became empty and EmptyRoomTTL == 0: the room is removed from servers and should be removed from lobby list.
    2. The room became empty and EmptyRoomTTL > 0: the room is empty (PlayerCount = 0) and the rest of the info remains the same.
    3. The room is not empty: PlayerCount is decremented by 1 and the rest of the info remains the same.



    In the screenshot, I tested using 2 clients.
    One client remains in the lobby.
    The other client creates a room named X with a lobby property K:V and EmptyRoomTTL > 0 and IsOpen=true and MaxPlayers=0.
    Later the client updates the lobby property value K:V1.
    Later the client updates lobby properties keys from K to K,K1.
    After that the client leaves the room.
    After EmptyRoomTTL expiration the room is removed.

    Keys:
    252: PlayerCount
    251: RemovedFromTheList
    255: MaxPlayers
    253: IsOpen
  • olistan
    Options
    Thanks for your help @JohnTube , the problem was that I wasn't aware of the "RemovedFromList" field. The missing properties were in a RoomInfo with RemovedFromList == true (which makes total sense, no need to send these properties if the room has been deleted).

    Now that I'm handling room list updates similarly to the Asteroids demo, I'm not getting the errors anymore. :)