Fix #59 (#102)
All checks were successful
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/head This commit looks good

Fix #59
This commit is contained in:
Louis Royer 2020-04-02 02:48:40 +02:00
parent 9d4c98c466
commit 4928efa947
3 changed files with 10 additions and 1 deletions

View File

@ -66,7 +66,6 @@ public abstract class ServerManagement extends ServeErrors implements Runnable {
stop = true;
fileListWatcher.setStop();
ratioWatcher.setStop();
sendUnregisterRequest();
closeSocket();
writeLog("Server stopped", LogLevel.Info);
}

View File

@ -78,6 +78,11 @@ public class ServerManagementTCP extends ServerManagement {
*/
public void run() {
writeLog("Server sucessfully started", LogLevel.Info);
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
sendUnregisterRequest();
}
});
fileListWatcher = (FileWatcher)new FileWatcherTCP(logger, 10000, server, tracker, baseDirectory); // checking every 10 seconds
Thread flwt = new Thread(fileListWatcher);
flwt.start();

View File

@ -73,6 +73,11 @@ public class ServerManagementUDP extends ServerManagement {
*/
public void run() {
logger.writeUDP("Server sucessfully started", LogLevel.Info);
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
sendUnregisterRequest();
}
});
fileListWatcher = (FileWatcher)new FileWatcherUDP(logger, 10000, server, tracker, baseDirectory); // checking every 10 seconds
Thread flwt = new Thread(fileListWatcher);
flwt.start();