JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
clients ask/get initial state on [re]load
[peach-cgt.git] / client.coffee
index fbe2815..6f8d230 100644 (file)
@@ -120,14 +120,19 @@ init = ->
                @cards[card].view.toggleClass 'flipped', state
                if agent is me
                        tell_server ['flip', agent, card, state]
-       state.on 'set_cards', (cards) ->
+       state.on 'set_cards', (agent, cards) ->
                # FIXME add agent arg and tell server if it's not us
                $('.card').remove()
                for card in cards
                        instantiate_card card
+               if agent is me
+                       tell_server ['set_cards', agent, cards]
 
        # timeout so browser will stop showing that we're loading
        timeout 1, poll_for_updates
+       timeout 2, ->
+               # ask for initial state
+               tell_server ['send_state', state.agent]
 
 $ ->
        $table = $ '#table'