mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-22 16:23:20 +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
|
@Override
|
||||||
public void onUserAccountConnectedEvent(String username) {
|
public void onUserAccountConnectedEvent(String username) {
|
||||||
firerer.fireStartupValidated();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserAccountDisconnectedEvent(String username) {
|
public void onUserAccountDisconnectedEvent(String username) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartupProcedureFinishedEvent(boolean success) {
|
||||||
|
if(success)
|
||||||
|
firerer.fireStartupValidated();
|
||||||
|
|
||||||
|
startupProcessBegan = false;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.handle();
|
.handle();
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ class StartupProcedureHandler {
|
|||||||
System.out.println(" --> Compte inconnu");
|
System.out.println(" --> Compte inconnu");
|
||||||
//Compte spécifié inconnu
|
//Compte spécifié inconnu
|
||||||
firerer.fireUserAccountUnknownEvent(username);
|
firerer.fireUserAccountUnknownEvent(username);
|
||||||
|
firerer.fireStartupProcedureFinishedEvent(false);
|
||||||
}else{
|
}else{
|
||||||
//TODO remove sysout
|
//TODO remove sysout
|
||||||
System.out.println(" --> Compte connu");
|
System.out.println(" --> Compte connu");
|
||||||
@ -88,6 +89,7 @@ class StartupProcedureHandler {
|
|||||||
}
|
}
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
firerer.fireStartupProcedureFinishedEvent(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +108,7 @@ class StartupProcedureHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void onPQTPingFailureEvent(String host, Integer port, Throwable cause) {
|
public void onPQTPingFailureEvent(String host, Integer port, Throwable cause) {
|
||||||
StartupProcedureHandler.this.removePingListener();
|
StartupProcedureHandler.this.removePingListener();
|
||||||
|
firerer.fireStartupProcedureFinishedEvent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -153,16 +156,25 @@ class StartupProcedureHandler {
|
|||||||
//Compte connecté
|
//Compte connecté
|
||||||
//TODO remove sysout
|
//TODO remove sysout
|
||||||
System.out.println("Connecté en tant que '"+username+"'");
|
System.out.println("Connecté en tant que '"+username+"'");
|
||||||
|
|
||||||
StartupProcedureHandler.this.removeConnectAccountListener();
|
StartupProcedureHandler.this.removeConnectAccountListener();
|
||||||
firerer.fireUserAccountConnectedEvent(username);
|
firerer.fireUserAccountConnectedEvent(username);
|
||||||
|
firerer.fireStartupProcedureFinishedEvent(true);
|
||||||
}else{
|
}else{
|
||||||
//Compte non-connecté
|
//Compte non-connecté
|
||||||
//TODO remove sysout
|
//TODO remove sysout
|
||||||
System.out.println("Non-connecté en tant que '"+username+"'");
|
System.out.println("Non-connecté en tant que '"+username+"'");
|
||||||
StartupProcedureHandler.this.removeConnectAccountListener();
|
|
||||||
firerer.fireUserAccountDisconnectedEvent(username);
|
firerer.fireUserAccountDisconnectedEvent(username);
|
||||||
|
firerer.fireStartupProcedureFinishedEvent(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountStatusNotChangedEvent(Throwable cause) {
|
||||||
|
StartupProcedureHandler.this.removeConnectAccountListener();
|
||||||
|
firerer.fireStartupProcedureFinishedEvent(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return connectAccountListener;
|
return connectAccountListener;
|
||||||
|
@ -6,6 +6,7 @@ public interface IStartupProcedureEventFirerer {
|
|||||||
void fireUserAccountUnknownEvent(String username);
|
void fireUserAccountUnknownEvent(String username);
|
||||||
void fireUserAccountConnectedEvent(String username);
|
void fireUserAccountConnectedEvent(String username);
|
||||||
void fireUserAccountDisconnectedEvent(String username);
|
void fireUserAccountDisconnectedEvent(String username);
|
||||||
|
void fireStartupProcedureFinishedEvent(boolean success);
|
||||||
|
|
||||||
void addListener(IStartupProcedureListener l );
|
void addListener(IStartupProcedureListener l );
|
||||||
void removeListener(IStartupProcedureListener l );
|
void removeListener(IStartupProcedureListener l );
|
||||||
|
@ -8,4 +8,5 @@ public interface IStartupProcedureListener extends EventListener{
|
|||||||
void onUserAccountUnknownEvent(String username);
|
void onUserAccountUnknownEvent(String username);
|
||||||
void onUserAccountConnectedEvent(String username);
|
void onUserAccountConnectedEvent(String username);
|
||||||
void onUserAccountDisconnectedEvent(String username);
|
void onUserAccountDisconnectedEvent(String username);
|
||||||
|
void onStartupProcedureFinishedEvent(boolean success);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,12 @@ public class SimpleStartupProcedureEventFirerer implements IStartupProcedureEven
|
|||||||
.forEach(l->l.onUserAccountDisconnectedEvent(username));
|
.forEach(l->l.onUserAccountDisconnectedEvent(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fireStartupProcedureFinishedEvent(boolean success) {
|
||||||
|
Arrays.stream(listenerList.getListeners(IStartupProcedureListener.class))
|
||||||
|
.forEach(l->l.onStartupProcedureFinishedEvent(success));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(IStartupProcedureListener l) {
|
public void addListener(IStartupProcedureListener l) {
|
||||||
listenerList.add(IStartupProcedureListener.class, l);
|
listenerList.add(IStartupProcedureListener.class, l);
|
||||||
|
Loading…
Reference in New Issue
Block a user