Tutoriel 4: utiliser la SessionPong
#
Ajouter une méthode appliquerA dans les événements
#
-
Dans
EvtAfficherPartiepublic class EvtAfficherPartie extends Event { // ... // ajouter public EvtAfficherPartie appliquerA(SessionPong session) { session.memoriserVueCourante(VuePartie.class); return this; } } -
Dans
EvtAfficherFileAttentepublic class EvtAfficherFileAttente extends Event { // ... // ajouter public EvtAfficherFileAttente appliquerA(SessionPong session) { session.memoriserVueCourante(VueFileAttente.class); return this; }
Dans les tâche de Navigation, mémoriser la vue courante
#
-
Dans
Navigation, modifier la méthodeafficherVuePartieprivate static void afficherVuePartie(FrontendTasks subTasks) { subTasks.task("afficherVuePartie") .waitsFor(event(EvtAfficherPartie.class)) .waitsFor(created(VueRacine.class)) .waitsFor(created(VuePartie.class)) .executes(inputs -> { // ajouter SessionPong session = Ntro.session(); EvtAfficherPartie evtAfficherPartie = inputs.get(event(EvtAfficherPartie.class)); VueRacine vueRacine = inputs.get(created(VueRacine.class)); VuePartie vuePartie = inputs.get(created(VuePartie.class)); // modifier evtAfficherPartie.appliquerA(session) .appliquerA(vueRacine, vuePartie); }); } -
Dans
Navigation, modifier la méthodeafficherVueFileAttenteprivate static void afficherVueFileAttente(FrontendTasks subTasks) { subTasks.task("afficherVueFileAttente") .waitsFor(event(EvtAfficherFileAttente.class)) .waitsFor(created(VueRacine.class)) .waitsFor(created(VueFileAttente.class)) .executes(inputs -> { // ajouter SessionPong session = Ntro.session(); EvtAfficherFileAttente evtAfficherFileAttente = inputs.get(event(EvtAfficherFileAttente.class)); VueRacine vueRacine = inputs.get(created(VueRacine.class)); VueFileAttente vueFileAttente = inputs.get(created(VueFileAttente.class)); // modifier evtAfficherFileAttente.appliquerA(session) .appliquerA(vueRacine, vueFileAttente); }); }
Dans les tâches du PremierAffichage, afficher la vue courante
#
-
Dans
SessionPong, ajouter une méthode pour déclencher l’événement selon la vue courantepublic class SessionPong extends Session<SessionPong> { // ... // ajouter public void envoyerEvtPourAfficherVueCourante() { if(vueCourante.equals(VuePartie.class)) { Ntro.newEvent(EvtAfficherPartie.class) .trigger(); }else { Ntro.newEvent(EvtAfficherFileAttente.class) .trigger(); } } -
Dans
PremierAffichage.choisirPremiereVue, appler la nouvelle métodeprivate static void choisirPremiereVue(FrontendTasks subTasks) { subTasks.task("choisirPremiereVue") .waitsFor(created(VueRacine.class)) .waitsFor(created(VueFileAttente.class)) // ajouter .waitsFor(created(VuePartie.class)) // ajouter .waitsFor(session(SessionPong.class)) .executes(inputs -> { // remplacer le code de cette tâche par SessionPong session = inputs.get(session(SessionPong.class)); session.envoyerEvtPourAfficherVueCourante(); }); }