Master client disconnects before setting important player and room properties

I have a situation where if the flag is captured, an RPC is called by the master client, which invokes an event (not PUN event) on each of the clients. This event then eventually reaches a function in which the master client has to set certain room and player properties. A snippet of this code.

PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { PlayerProperty.Objective, null } });

Only the master client reaches these lines. However, if the master client disconnects before one of those lines then the properties are never set and things go broken since events are already called on other clients (thanks to the RPC).

What would be a workaround for this problem? Can I somehow use expected values or expected users and call these SetCustomProperties on all clients. So that even if the master client disconnects, one of the other clients will still execute these functions.

Comments

  • Majicpanda
    edited July 2017
    You could possibly use OnMasterClientSwitched and then check all player properties and if any are missing the Objective property, try to re-process everyone back to null?

    public override void OnMasterClientSwitched(PhotonPlayer newMasterClient) { }

    I use InstantiateSceneObject on a singleton called ServerEvents so that I can keep a game state of sorts always available to the Masterclient. InstantiateSceneObject makes the PhotonView belong to the room and not any specific player, so transfer is automatic. You'll probably just need to re-run sanity checks.. not too uncommon for games to toss up a message while re-syncing.
  • Thanks for the reply. I thought about your proposed solution as well. However, I thought maybe there is another built-in solution available. For example, each user changes the custom properties but only the first one is accepted. Rest are ignored. Suppose I could program this myself.
  • Not sure if it's of any use but Custom Properties does support sending what "should" be there vs what the player wants to send, and if what's on the server doesn't match what is in the 2nd param it will reject the property change. Maybe that would help with sync depending on how you have your OnPropertiesChanged callback?

    Check and Swap
    https://doc-api.photonengine.com/en/pun/current/class_photon_player.html#af8815abb8edaafbe6bddbf328f9612fb