From 9f80fa0e9d9822c4abba34604cbdb9a72ab04129 Mon Sep 17 00:00:00 2001 From: "Notmoo-PC\\Notmoo" Date: Wed, 8 Nov 2017 22:42:16 +0100 Subject: [PATCH] =?UTF-8?q?Module=20Client,=20startup=20procedure=20:=20aj?= =?UTF-8?q?out=20d'un=20nouvel=20event=20StartupProcedureFinished,=20lev?= =?UTF-8?q?=C3=A9=20quand=20la=20proc=C3=A9dure=20de=20d=C3=A9marrage=20(p?= =?UTF-8?q?ing=20+=20connexion)=20se=20termine,=20peu=20importe=20le=20r?= =?UTF-8?q?=C3=A9sultat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frames/startup_frame/StartupFrameModel.java | 9 ++++++++- .../startup_frame/StartupProcedureHandler.java | 14 +++++++++++++- .../procedure/IStartupProcedureEventFirerer.java | 1 + .../procedure/IStartupProcedureListener.java | 1 + .../SimpleStartupProcedureEventFirerer.java | 6 ++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java index 9039216c..3e64123a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java @@ -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(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java index 453481bb..120e1030 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java @@ -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; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java index 93c9b061..9fa2ba3c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java @@ -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 ); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java index 6f0968e4..17d95820 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java @@ -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); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java index 97a0693e..aa2f6fa2 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java @@ -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);