Setting room CustomProperties seems to cause disconnect/reload of scene

Options

The code below manages sync of room properties between clients i.e. If I change a value that needs to sync (LEVEL_STATE or currentLevelStartTime) I change it, set roomPropertiesDirty = true and it will get updated on the next frame in the call to SetRoomState() in the update loop.

This process has always worked but (I think) since I updated Photon (from 2.22 to 2.34.1), the first (masterclient) connects OK, but when a second player joins the room, they seem to disconnect and rejoin over and over. If I comment out the call to SetRoomState() this doesn't happen.

I can't see what else would cause this in my code - have there been any recent changes that I should look into that could break this?

Thanks!
    private void SetRoomState()
    {
        if (roomPropertiesDirty)
        {
            ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();

            properties.Add("LEVEL_STATE", LEVEL_STATE.ToString());
            properties.Add("currentLevelStartTime", currentLevelStartTime.ToString());
            PhotonNetwork.CurrentRoom.SetCustomProperties(properties);
            photonView.RPC("GetRoomState", RpcTarget.Others);
            roomPropertiesDirty = false;
        }
    }

    [PunRPC]
    public void GetRoomState()
    {
        LEVEL_STATE = (CASTLE_LEVEL_STATE)Enum.Parse(typeof(CASTLE_LEVEL_STATE), PhotonNetwork.CurrentRoom.CustomProperties["LEVEL_STATE"].ToString());
        currentLevelStartTime = Convert.ToDouble(PhotonNetwork.CurrentRoom.CustomProperties["currentLevelStartTime"]);
        roomPropertiesDirty = false;
    }

    void Update()
    {
        SetRoomState();
        ...
        if (something)
        {
                LEVEL_STATE = newState;
                roomPropertiesDirty = true;
        }
        ...
    }








Comments

  • I tried similar code in a level which doesn't currently use properties and has worked fine (multiple players can join, etc.).
    I added the code above with just one random property name (so that it has no effect on anything else) and I even tried removing the GetRoomState RPC call to other clients. It looks like the call to "PhotonNetwork.CurrentRoom.SetCustomProperties(properties);" is enough to cause the level to reload. I'd really appreciate any pointers on what to look for here. Thanks!
  • If I use JoinRandomRoom to connect to a room that was created with RoomOptions, like this...:
                var o = new RoomOptions();
                o.IsVisible = true;
                o.IsOpen = true;
                o.PublishUserId = true;
    
                o.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable
                {
                    {"SceneName, "myscene"}
                };
                o.CustomRoomPropertiesForLobby = new string[] { "SceneName" }
    

    ...does the use of "PhotonNetwork.CurrentRoom.SetCustomProperties(properties)" to add new properties to the room somehow invalidate players already in the room and have them kicked out?
  • NotQuiteSmith
    edited August 2021
    Options
    This previous bug/discussion may not be directly related - but it hints perhaps that there is some background processing happening, inside Photon, that links the setting of room properties with the loading of scene data.

    https://forum.photonengine.com/discussion/6773/restarting-level-problem

    Could anyone from Photon please help me understand what could be wrong? I understand the problem could be MY code but as far as I can see, it's the single call to SetCustomProperties that triggers this - none of my code runs between SetCustomProperties and whatever code causes my scene to get destroyed/reloaded!
  • ANLevant
    ANLevant
    edited March 2022
    Options

    Having the same issue. Still no one answers

  • Tobias
    Options

    Describe your issue, what you do and the issue.

    We can't help when you just hijack an old topic, which is certainly about a different version of PUN 2.

    There is a doc about what we need to help.