ajax - State Change After Update (by Another User) But Before Poll -


suppose have following scenario:

  1. 2 users both signal ready play, rails app receives , starts game
  2. one of 2 users issue "forfeit" via ajax (im assuming it's not possible prevent that, amirite?)
  3. by time other user polls figure out whether game has started, game has ended , scores updated
  4. that user confused

i'm not quite sure here. can give me ideas?


alright, figured out did wrong. (cant self answer yet because rep low)

when user polls figure out whether his/her game has started, , receive moves , etc, check "game in progress" , "user = user polling" attributes figure out respond. that's wrong, because ends, logic fails find relevant game retrieve data , give user.

what i'm think of right is, add "end game has been polled" attribute game object (well, playing objects through relationships) if game ended has not been polled, user receive once respond confirm. game not polled again.

the flag indicating game has ended should allow different values indicating why game ended. when player 1 forfeits, flag updated indicate forfeiture. when player 2 polls status, told of forfeiture.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -