Locking a property without setting one

0 votes
My question is simple. Can I lock a property of a room without setting a value for it at the same call?

I am using a property that keeps a count of players that are done loading relevant data on that game. Since one cannot guarantee the delay between getting room info and setting properties the following problem is possible:

player 1 gets the value of ReadyToStart (int)

player 2 gets value of ReadyToStart

Player 2 updates ReadyToStart to 1

player 1 updates readyToStart to 1

Both players are waiting fo the other to update

I know I could just make a separate value for each player, but since I am using the same code to manage different games this is not feasable.
asked Jul 18, 2014 in AppWarpS2 by kari (10 points)

1 Answer

0 votes

"I know I could just make a separate value for each player, but since I am using the same code to manage different games this is not feasable."

I am not sure why this is a problem. Each player can lock a property with key as its username and value "true". Since usernames are unique across CCUs and your client app will anyway know what the local username is, this should a viable approach.

Player A locks {A:true}

Player B locks {B:true}

Whenever a property is locked a notification is sent to all the users in the room with the property and lock table. When you get this notification and if the lock table has 2 entries - then you can safely assume that both you and other player are ready to start.

 

answered Jul 20, 2014 by dhruvc (1,099 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...