mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Removed unused import statements and class variables. Removed non error print statements.
This commit is contained in:
@@ -29,8 +29,6 @@ public class ServerThread implements Runnable, Observer {
|
||||
Thread runner = new Thread(this, threadName);
|
||||
runner.setDaemon(true);
|
||||
|
||||
serverLog("Spawning Server", 0);
|
||||
|
||||
raceSimulator = new Simulator(BOAT_LOCATION_PERIOD);
|
||||
raceSimulator.addObserver(this);
|
||||
// run race simulator, so it can send boats' static location.
|
||||
@@ -134,7 +132,6 @@ public class ServerThread implements Runnable, Observer {
|
||||
* Starts an instance of the race simulator
|
||||
*/
|
||||
private void startRaceSim(){
|
||||
serverLog("Starting Running Race Simulator", 0);
|
||||
// set race started to true, so the simulator will start moving boats
|
||||
raceSimulator.setRaceStarted(true);
|
||||
}
|
||||
@@ -142,8 +139,7 @@ public class ServerThread implements Runnable, Observer {
|
||||
/**
|
||||
* Starts sending heartbeat messages to the client
|
||||
*/
|
||||
private void startSendingHeartbeats(){
|
||||
serverLog("Sending Heartbeats", 0);
|
||||
private void startSendingHeartbeats() {
|
||||
Timer t = new Timer();
|
||||
|
||||
t.schedule(new TimerTask() {
|
||||
@@ -154,7 +150,7 @@ public class ServerThread implements Runnable, Observer {
|
||||
try {
|
||||
server.send(heartbeat);
|
||||
} catch (IOException e) {
|
||||
System.out.print("");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, HEARTBEAT_PERIOD);
|
||||
@@ -174,14 +170,13 @@ public class ServerThread implements Runnable, Observer {
|
||||
if (startTime < System.currentTimeMillis() && !raceStarted){
|
||||
startRaceSim();
|
||||
raceStarted = true;
|
||||
serverLog("Race Started", 0);
|
||||
}
|
||||
else{
|
||||
server.send(raceStartStatusMessage);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.print("");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, RACE_START_STATUS_PERIOD);
|
||||
@@ -191,7 +186,6 @@ public class ServerThread implements Runnable, Observer {
|
||||
* Start sending race start status messages until race starts
|
||||
*/
|
||||
private void startSendingRaceStatusMessages(){
|
||||
serverLog("Sending race status messages", 0);
|
||||
Timer t = new Timer();
|
||||
t.schedule(new TimerTask() {
|
||||
@Override
|
||||
@@ -199,9 +193,8 @@ public class ServerThread implements Runnable, Observer {
|
||||
Message raceStatusMessage = getRaceStatusMessage();
|
||||
try {
|
||||
server.send(raceStatusMessage);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.print("");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, RACE_STATUS_PERIOD);
|
||||
@@ -218,17 +211,12 @@ public class ServerThread implements Runnable, Observer {
|
||||
|
||||
if (raceData != null){
|
||||
server.send(raceData);
|
||||
serverLog("Sending race data", 0);
|
||||
}
|
||||
|
||||
if (boatData != null){
|
||||
server.send(boatData);
|
||||
serverLog("Sending boat data", 0);
|
||||
}
|
||||
|
||||
if (regatta != null){
|
||||
server.send(regatta);
|
||||
serverLog("Sending regatta data", 0);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
serverLog("Couldn't send an XML Message: " + e.getMessage(), 0);
|
||||
@@ -247,7 +235,6 @@ public class ServerThread implements Runnable, Observer {
|
||||
Message raceData = getXmlMessage("/server_config/courseLimits.xml", XMLMessageSubType.RACE);
|
||||
if (raceData != null) {
|
||||
server.send(raceData);
|
||||
serverLog("Sending race data", 0);
|
||||
}
|
||||
}catch (IOException e) {
|
||||
serverLog("Couldn't send an XML Message: " + e.getMessage(), 0);
|
||||
@@ -295,7 +282,7 @@ public class ServerThread implements Runnable, Observer {
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.print("");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, BOAT_LOCATION_PERIOD);
|
||||
@@ -322,7 +309,6 @@ public class ServerThread implements Runnable, Observer {
|
||||
numOfBoatsFinished ++;
|
||||
if (!boatsFinished.get(boat.getSourceID())) {
|
||||
boatsFinished.put(boat.getSourceID(), true);
|
||||
serverLog("Boat " + boat.getSourceID() + " finished the race", 1);
|
||||
}
|
||||
}
|
||||
Message m = new BoatLocationMessage(boat.getSourceID(), 1, boat.getLat(),
|
||||
|
||||
@@ -28,7 +28,6 @@ class StreamingServerSocket {
|
||||
}
|
||||
|
||||
void start(){
|
||||
ServerThread.serverLog("Listening For Connections",0);
|
||||
try {
|
||||
client = socket.accept();
|
||||
} catch (IOException e) {
|
||||
@@ -39,7 +38,6 @@ class StreamingServerSocket {
|
||||
}
|
||||
else{
|
||||
isServerStarted = true;
|
||||
ServerThread.serverLog("client connected from " + client.socket().getInetAddress(),0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ public class Simulator extends Observable implements Runnable {
|
||||
numOfFinishedBoats += moveBoat(boat, lapse);
|
||||
}
|
||||
}
|
||||
//System.out.println(boats.get(0));
|
||||
|
||||
setChanged();
|
||||
notifyObservers(boats);
|
||||
@@ -65,8 +64,6 @@ public class Simulator extends Observable implements Runnable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("[SERVER] Race simulator has been terminated");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user