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:
Notmoo-PC\Notmoo 2017-11-08 22:42:16 +01:00
parent b9de88a43f
commit 9f80fa0e9d
5 changed files with 29 additions and 2 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -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 );

View File

@ -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);
}

View File

@ -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);