Documented client packet parser, client state, client state querying runnable, client to server thread and replaced e.printStackTrace() with client log messages.

This commit is contained in:
Zhi You Tan
2017-07-26 16:01:41 +12:00
parent 2bfa6cb038
commit af9f1417f1
4 changed files with 61 additions and 37 deletions
@@ -12,6 +12,10 @@ public class ClientStateQueryingRunnable extends Observable implements Runnable
public ClientStateQueryingRunnable() {}
/**
* Notifies observers "game started" if ClientState raceStarted flag is true and terminates itself.
* Notifies observers "update players" if ClientState boatsUpdated flag is true and resets the flag to false;
*/
@Override
public void run() {
while(!terminate) {
@@ -29,14 +33,19 @@ public class ClientStateQueryingRunnable extends Observable implements Runnable
terminate();
}
if (ClientState.isDirtyState()) {
if (ClientState.isBoatsUpdated()) {
setChanged();
notifyObservers("update players");
ClientState.setDirtyState(false);
ClientState.setBoatsUpdated(false);
}
}
}
/**
* Used to terminate the thread.
*
* Currently called by the main while loop when game started is detected.
*/
public void terminate() {
terminate = true;
}