Issue 19 changes.

This commit is contained in:
David Wu
2017-08-17 12:50:41 +12:00
parent 8498701091
commit 6bc81f566e
7 changed files with 71 additions and 8 deletions
@@ -101,6 +101,13 @@ public class ConnectionAcceptor implements Runnable {
return serverPort;
}
public void closeConnection() throws IOException {
this.raceLogic.boolFalse();
if(!this.serverSocket.isClosed()){
this.serverSocket.close();
}
}
/**
@@ -113,6 +120,9 @@ public class ConnectionAcceptor implements Runnable {
try {
if(Thread.currentThread().isInterrupted()){
break;
}
Socket mockSocket = serverSocket.accept();
@@ -60,6 +60,10 @@ public class Event {
*/
private SourceIdAllocator sourceIdAllocator;
private Thread raceThread;
private Thread connectionThread;
@@ -130,7 +134,8 @@ public class Event {
this.latestMessages,
this.compositeCommand);
new Thread(newRace, "Event.Start()->RaceLogic thread").start();
this.raceThread = new Thread(newRace, "Event.Start()->RaceLogic thread");
raceThread.start();
//Create connection acceptor.
@@ -143,13 +148,20 @@ public class Event {
}
new Thread(connectionAcceptor, "Event.Start()->ConnectionAcceptor thread").start();
this.connectionThread = new Thread(connectionAcceptor, "Event.Start()->ConnectionAcceptor thread");
connectionThread.start();
sendXMLs();
}
public void endEvent() throws IOException {
this.connectionThread.interrupt();
this.connectionAcceptor.closeConnection();
this.raceThread.interrupt();
}
/**