How to keep RPC in room after players leave

Options
Hi,

I am making a game that requires sending a lot of buffered RPCs but if the player who sent them leaves the room, then their RPCs are cleaned up, so players joining after someone leaves will receive mismatching state. Is there any way to keep buffered RPCs as part of the room or are there other ways to catch the player up to the correct state after someone leaves?

I understand that the same problem would occur even if other players asked master client to send buffered RPC, as when master client leaves, then his RPCs will get removed too.

Thanks.

Comments

  • vadim
    Options
    Buffered RPCs live as long as object on which they were triggered exists because client receives RPCs via this object instances. By default all player's objects destroyed on disconnect. Use PhotonNetwork.autoCleanUpPlayerObjects to avoid objects destruction (see doc for details).
    Note also that "sending a lot of buffered RPCs" is not best idea since buffer may contain useless history and involves in this case a lot of data transfer on new player join. Consider updating new players with current game state from master client.
  • thef0rce
    Options
    Thanks. I changed it so that I used room properties instead for something I used to use buffered RPC for.

    For the other thing I am working on, I was thinking I would listen to the player connected event and if I am the master client then I would send the joining player RPCs to catch them up on state. I think that would work, right?
  • thef0rce
    Options
    After thinking about it, I am wondering when I should use a buffered RPC. I originally thought that they were for updating state to players, because I thought that they stayed in the room for the whole duration. So what are they meant to be used for?

    Sorry for all the questions. Just trying to understand
  • vadim
    Options
    For the other thing I am working on, I was thinking I would listen to the player connected event and if I am the master client then I would send the joining player RPCs to catch them up on state. I think that would work, right?
    This is exactly what I wrote about. Room properties or player properties are good choice as well. They are updated automatically on existing or new clients.
    when I should use a buffered RPC
    If you have few RPC's per game session, it's easier sometimes make them buffered and get new joined player updated automatically. When this simple scheme does not work because of too much RPC's or removed player's object, you need to switch to another way of synchronization.