jfreerails.network
Class MovePrecommitter

java.lang.Object
  extended by jfreerails.network.MovePrecommitter

public class MovePrecommitter
extends java.lang.Object

The class pre-commits moves we intend to send to the server and either fully commits or undoes them depending on the server's response. Note, this class does not actually send or receive moves, instead you should call toServer(.) when a move has been sent to the server and fromServer(.) when a Move or MoveStatus has been received from the server.

Author:
Luke

Nested Class Summary
private static class MovePrecommitter.PreMoveAndMove
           
 
Field Summary
(package private)  boolean blocked
          Whether the first move on the uncommitted list failed to go through on the last try.
private static java.util.logging.Logger logger
           
(package private)  java.util.LinkedList<FreerailsSerializable> precomitted
          List of moves and premoves that have been sent to the server and executed on the local world object.
(package private)  java.util.LinkedList<FreerailsSerializable> uncomitted
          List of moves and premoves that have been sent to the server but not executed on the local world object.
private  World w
           
 
Constructor Summary
MovePrecommitter(World w)
           
 
Method Summary
(package private)  void fromServer(Move m)
           
(package private)  void fromServer(MoveStatus ms)
          Indicates that the server has processed a move we sent.
(package private)  Move fromServer(PreMove pm)
           
(package private)  void fromServer(PreMoveStatus pms)
           
(package private)  void precommitMoves()
           
private  void rollBackPrecommittedMoves()
          Undoes each of the precommitted moves and puts them back on the uncommitted list.
(package private)  void toServer(Move m)
           
(package private)  Move toServer(PreMove pm)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

blocked

boolean blocked
Whether the first move on the uncommitted list failed to go through on the last try.


precomitted

final java.util.LinkedList<FreerailsSerializable> precomitted
List of moves and premoves that have been sent to the server and executed on the local world object.


uncomitted

final java.util.LinkedList<FreerailsSerializable> uncomitted
List of moves and premoves that have been sent to the server but not executed on the local world object.


w

private final World w
Constructor Detail

MovePrecommitter

MovePrecommitter(World w)
Method Detail

fromServer

void fromServer(Move m)

fromServer

void fromServer(MoveStatus ms)
Indicates that the server has processed a move we sent.


fromServer

Move fromServer(PreMove pm)

fromServer

void fromServer(PreMoveStatus pms)

precommitMoves

void precommitMoves()

rollBackPrecommittedMoves

private void rollBackPrecommittedMoves()
Undoes each of the precommitted moves and puts them back on the uncommitted list.


toServer

void toServer(Move m)

toServer

Move toServer(PreMove pm)