CustomRoomPropertiesForLobby is not working for PUN2

Options
Hello!

I am working on disconnects with using a mobile device. When the device either goes to sleep or loses focus, they drop connection. My game is turned based and there may be times there may be minutes between movements and do not need per second access. Using PhotonCloud.

This is fine, but I want when app gets focus again, to rejoin the room. The rejoin isn't working the way I want so my thought was to save a GUID in the RoomInfo and then, when reconnected to the lobby, search for the last room they were in by the RoomInfo GUID and rejoin.

I think this was working fine in PUN, but with PUN2, it's seems I'm not following. All I wanted was to just call GetRoomList(), check all the RoomInfo and match the GUID, and Join that room.

I have created my room with the CustomerRoomProperties fine:
        Guid id = Guid.NewGuid();

        ExitGames.Client.Photon.Hashtable prop = new ExitGames.Client.Photon.Hashtable();
        prop.Add("GM_GUID", id.ToString());
        prop.Add("GM_RoomCreatedTime", DateTime.Now.ToString());

        RoomOptions roomOps = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 0, EmptyRoomTtl = 300000, CustomRoomProperties = prop };

And in this code:
    public override void OnRoomListUpdate(List<RoomInfo> roomList) 
    {
        //roomListings.Clear();
        roomListings = roomList;

        _ListRooms = new List<string>();

        Debug.Log("PhotoLobby recognizes OnRoomListUpdate fired ");
        //int tempIndex;
        foreach (RoomInfo room in roomList) //loop through each room in room list
        {
            Debug.Log("room info:" + room.Name);
            _ListRooms.Add(room.Name);

            foreach (var item in room.CustomProperties)
            {
                Debug.Log("key: " + item.Key.ToString());
                Debug.Log("value: " + item.Value.ToString());
            }
        }
    }
I will never see the room.CustomerProperties.

What am I missing?
Thanks!


Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2020
    Options
    Hi @matrix211v2,

    Did you forget to specify which custom room properties should be visible to the lobby?
    Although it's mentioned in the discussion title, I don't see it in the snippet:
    roomOps.CustomRoomPropertiesForLobby = new[] { "GM_GUID", "GM_RoomCreatedTime" };
    
    The rejoin isn't working the way I want so my thought was to save a GUID in the RoomInfo and then, when reconnected to the lobby, search for the last room they were in by the RoomInfo GUID and rejoin.
    Not sure why the rejoin isn't working properly. Could you explain how? Maybe save the last room name locally on the device (e.g. PlayerPrefs)?
    And what is this GUID? how can it identify the last joined room?