Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	app/src/main/resources/appdata.json
This commit is contained in:
Benjamin 2022-03-14 11:12:59 +01:00
commit 1689e2014f
4 changed files with 15 additions and 11 deletions

View File

@ -45,7 +45,6 @@ public class StoreProcessor extends Thread implements AutoCloseable {
this.store = socket;
this.protocolRep = protocolRep;
this.client_run = false;
initStore();
}
/**
@ -55,7 +54,7 @@ public class StoreProcessor extends Thread implements AutoCloseable {
* @see PrintWriter
* @since 1.0
*/
private void initStore() {
public void startStore() {
try {
this.reader = new BufferedReader(new InputStreamReader(
this.store.getInputStream(),

View File

@ -70,13 +70,15 @@ public class MulticastServerListener implements Runnable {
HelloRule.Result readerResult = protocolRep.executeReader(null, data);
System.out.printf("Nouveau SBE : Domain=%s | Port=%d\n", readerResult.getDomain(), readerResult.getPort());
Socket socket = new Socket(packet.getAddress(), readerResult.getPort());
if (!this.repository.hasDomain(readerResult.getDomain())){
Socket socket = new Socket(packet.getAddress(), readerResult.getPort());
// Create the store processor
StoreProcessor storeProcessor = new StoreProcessor(socket, readerResult.getDomain(), ffe, protocolRep); // TODO <!!!> : Voir comment on procède get via repo ou ici ?!
// Create the store processor
StoreProcessor storeProcessor = new StoreProcessor(socket, readerResult.getDomain(), ffe, protocolRep); // TODO <!!!> : Voir comment on procède get via repo ou ici ?!
// Add the store processor to its repository
this.repository.addStore(storeProcessor);
// Add the store processor to its repository
this.repository.addStore(storeProcessor);
}
} catch (IOException ignore) {
ignore.printStackTrace();
}

View File

@ -19,7 +19,7 @@ public interface MulticastSPR {
* Add a StorePorcessor.
* @param store Store processor to add.
*/
void addStore(StoreProcessor store);
boolean addStore(StoreProcessor store);
String findDomain(Task task);

View File

@ -50,9 +50,12 @@ public class StoreProcessorRepository implements AutoCloseable, MulticastSPR {
* @since 1.0
*/
@Override
public void addStore(StoreProcessor store) {
this.handlers.add(store);
public boolean addStore(StoreProcessor store) {
if (!this.hasDomain(store.getDomain())) {
store.startStore();
return this.handlers.add(store);
}
return false;
}
@Override