There is a fourth state,
denoted by the STATE_WAITING constant, but that means exactly what it would seem to mean:
the thread is waiting for something, specifically acknowledgment from the client that the last
command the thread sent to it has completed, so any iteration that executes during that state
will result in nothing happening.
So, what happens when the thread picks the first tile (and actually, the same thing happens
when picking the second tile too)? The first thing that happens is a call to pickTile(),
which returns a number from 0 to 42. Next, the thread is put in the waiting state. Finally, that
ScriptBuffer we got earlier is used to call the InMemoria.opponentFlipTile() method, passing
it the number of the tile being flipped (either 1 or 2), the tile number that was chosen, and
what image appears there. This will cause the client to flip the tile and then send an acknowledgement
back to the thread. Recall when we looked at the client-side InMemoria class that
there were four methods I was going to leave out until later, because it made more sense to
look at them in the context of the server-side code? Well, the time has arrived to do so! Here is
the opponentFlipTile() method:
this.
Pages:
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768