Check and swap for properties (CAS): How to know which property set failed or not

Hi,

This page describe how to make use of CAS:


Now consider the following:

My players are in a 10 players room and walk around the map. By interacting with a specific gameobject on the map, they can trigger a small 2 player versus mini game. The 2 players competing in the mini game should still exist on the 10 player map (suggesting that they have to stay in the same 10 players room).

To make sure a mini game is triggered with only 2 players (and not 3 that would trigger at the same time) I'm implementing CAS on a custom property:

  1. Player A will set the "current_opponent" custom property of player B to "PlayerA".
  2. If CAS is successful, Player B will set the "current_opponent" of player A to "PlayerB".
  3. if CAS is successful again, the versus minigame will start.

Now my issue with this is that when a property is set and I check the CAS result in "NetworkingClientOnOpResponseReceived(OperationResponse opResponse)" I only get the result (success/fail), not which property was successful or not.

Is there a way to know which property the CAS response is refering to ?


Best regards,

Nicolas Schluchter

Answers

  • Sorry, that info is not exposed by CAS.

    If I recall correctly, the server will send the correct properties if a CAS attempt fails. This updates the client to the needed values (usually). This means you could check which values are "current" on the server and you could check versus the values you sent?!

  • Hi @Konni,

    Thank you for choosing Photon!

    As Tobias already mentioned, there is no way to tell currently which properties were failed to set due to CAS.

    The server replies with a generic error code and message.

    I have made an unofficial attempt to solve this problem (among other things) by making a PropertiesSetter class which sets properties one by one. Here. In order to use this class, you need to make all SetProperties calls through it as it queues them and sends them one by one. For instance, you have to set IsOpen, IsVisible, etc. using it. The good news is that PropertiesSetter allows setting multiple well known properties at once and allows mixing well known properties and custom ones in the same request.