mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-12-22 23:41:09 +00:00
Module Client, startup procedure : ajout d'un nouvel event StartupProcedureFinished, levé quand la procédure de démarrage (ping + connexion) se termine, peu importe le résultat
This commit is contained in:
parent
b9de88a43f
commit
9f80fa0e9d
@ -52,13 +52,20 @@ public class StartupFrameModel {
|
||||
|
||||
@Override
|
||||
public void onUserAccountConnectedEvent(String username) {
|
||||
firerer.fireStartupValidated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserAccountDisconnectedEvent(String username) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartupProcedureFinishedEvent(boolean success) {
|
||||
if(success)
|
||||
firerer.fireStartupValidated();
|
||||
|
||||
startupProcessBegan = false;
|
||||
}
|
||||
})
|
||||
.handle();
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ class StartupProcedureHandler {
|
||||
System.out.println(" --> Compte inconnu");
|
||||
//Compte spécifié inconnu
|
||||
firerer.fireUserAccountUnknownEvent(username);
|
||||
firerer.fireStartupProcedureFinishedEvent(false);
|
||||
}else{
|
||||
//TODO remove sysout
|
||||
System.out.println(" --> Compte connu");
|
||||
@ -88,6 +89,7 @@ class StartupProcedureHandler {
|
||||
}
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
firerer.fireStartupProcedureFinishedEvent(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,6 +108,7 @@ class StartupProcedureHandler {
|
||||
@Override
|
||||
public void onPQTPingFailureEvent(String host, Integer port, Throwable cause) {
|
||||
StartupProcedureHandler.this.removePingListener();
|
||||
firerer.fireStartupProcedureFinishedEvent(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -153,16 +156,25 @@ class StartupProcedureHandler {
|
||||
//Compte connecté
|
||||
//TODO remove sysout
|
||||
System.out.println("Connecté en tant que '"+username+"'");
|
||||
|
||||
StartupProcedureHandler.this.removeConnectAccountListener();
|
||||
firerer.fireUserAccountConnectedEvent(username);
|
||||
firerer.fireStartupProcedureFinishedEvent(true);
|
||||
}else{
|
||||
//Compte non-connecté
|
||||
//TODO remove sysout
|
||||
System.out.println("Non-connecté en tant que '"+username+"'");
|
||||
StartupProcedureHandler.this.removeConnectAccountListener();
|
||||
|
||||
firerer.fireUserAccountDisconnectedEvent(username);
|
||||
firerer.fireStartupProcedureFinishedEvent(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccountStatusNotChangedEvent(Throwable cause) {
|
||||
StartupProcedureHandler.this.removeConnectAccountListener();
|
||||
firerer.fireStartupProcedureFinishedEvent(false);
|
||||
}
|
||||
};
|
||||
}
|
||||
return connectAccountListener;
|
||||
|
@ -6,6 +6,7 @@ public interface IStartupProcedureEventFirerer {
|
||||
void fireUserAccountUnknownEvent(String username);
|
||||
void fireUserAccountConnectedEvent(String username);
|
||||
void fireUserAccountDisconnectedEvent(String username);
|
||||
void fireStartupProcedureFinishedEvent(boolean success);
|
||||
|
||||
void addListener(IStartupProcedureListener l );
|
||||
void removeListener(IStartupProcedureListener l );
|
||||
|
@ -8,4 +8,5 @@ public interface IStartupProcedureListener extends EventListener{
|
||||
void onUserAccountUnknownEvent(String username);
|
||||
void onUserAccountConnectedEvent(String username);
|
||||
void onUserAccountDisconnectedEvent(String username);
|
||||
void onStartupProcedureFinishedEvent(boolean success);
|
||||
}
|
||||
|
@ -35,6 +35,12 @@ public class SimpleStartupProcedureEventFirerer implements IStartupProcedureEven
|
||||
.forEach(l->l.onUserAccountDisconnectedEvent(username));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireStartupProcedureFinishedEvent(boolean success) {
|
||||
Arrays.stream(listenerList.getListeners(IStartupProcedureListener.class))
|
||||
.forEach(l->l.onStartupProcedureFinishedEvent(success));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IStartupProcedureListener l) {
|
||||
listenerList.add(IStartupProcedureListener.class, l);
|
||||
|
Loading…
Reference in New Issue
Block a user