Unable to Sync RPC value to clients joining later

Options
Hi,
As the title says, I'm unable to sync values on Clients Joining later i.e I send the RPC already and when a client joins it doesn't get buffered on its app.

Please note:
1. I am using RpcTarget.AllBuffered
2. The RPC gets sent on Click.

Here's my code:
    void Start()
    {
        testIF = GetComponent<TMP_InputField>();
        textTMP = GetComponent<TextMeshProUGUI>();
    }
    [PunRPC]
    public void testFunction( string testString)
    {
        textTMP.text = testString;
    }

    public void spawnBookmark()
    {
        PhotonView pv = GetComponent<PhotonView>();
        if (pv.IsMine)
        {
            pv.RPC("testFunction", RpcTarget.AllBuffered, testIF.text);
        }
    }
I am getting input from user on runtime and a assigned this function to button via inspector.

Important: The user (not master) gets the rpc when both have joined but RPC is not sent yet. But when the user joins later (after RPC is sent) it get the string send by rpc for a mili second before the original text appears again.

What am I doing wrong here any clues? I have just began with the RPC on Photon.

Any help would be appreciated.

Thanks in advance.

Answers

  • jeanfabre
    Options
    Hi,

    buffered rpc should be avoided, prefer using custom room properties to store data that the player needs when entering the room, this is safer, less problematic and easier to debug.

    Bye,

    Jean
  • Sikandar
    Options

    Hi Jean,
    The example is a simpler one, I'm taking input from this input field and have to spawn on different positions on screen (mouse click) custom room properties would be helpful if there static values that needs to be synced (like some settings room names etc) but my problem is a bit different.

    Thank.

    Regards,
    Sikandar

  • jeanfabre
    Options
    Hi,

    can you explain more in details your case then? cause I think think custom room properties is the way to go when one starts to use buffered RPC. Buffered RPC creates more problems than it solves.

    you can save your field input value in the a custom room property, it works exactly the same as if you sent an rpc to tell everyone about it.


    Bye,

    Jean
  • Sikandar
    Options

    Hi,
    So here's a scenario:
    I have an Object, a user (master client) clicks on it and can add a bookmark (bookmark includes: icon, text from this field) and it should be visible to everyone. Untill now, I'm able to spawn a prefab (which includes all this setup i.e its show input field and a button) now spawning works on all i.e sent from master to all. But the sending the Text is what os causing me problems so I thought I could use RPCs.

  • Sikandar
    Options
    Hi Jean,
    I followed your advice to use Custom Room Properties, could you please look at this:

    https://forum.photonengine.com/discussion/16147/is-it-possible-to-show-custom-properties-list-which-are-being-set-in-a-room

    and let me if you could shed some light on what I'm doing wrong?

    Thanks in advance.