DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

dcdb2639c124e8c51e7f0a812e6dc6117dd7a7a1 — Jonni Liljamo 1 year, 9 months ago 0308806
feat(client): handle AfterAuth message
2 files changed, 20 insertions(+), 5 deletions(-)

M client/src/plugins/networking/mod.rs
M client/src/plugins/networking/systems/events.rs
M client/src/plugins/networking/mod.rs => client/src/plugins/networking/mod.rs +2 -1
@@ 16,6 16,7 @@ impl Plugin for NetworkingPlugin {
    fn build(&self, app: &mut App) {
        app.add_system_to_stage(CoreStage::PreUpdate, systems::events::connect_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::reject_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::disconnect_events);
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::disconnect_events)
            .add_system_to_stage(CoreStage::PreUpdate, systems::events::message_events);
    }
}

M client/src/plugins/networking/systems/events.rs => client/src/plugins/networking/systems/events.rs +18 -4
@@ 8,14 8,18 @@

use bevy::prelude::*;
use iyes_loopless::state::NextState;
use laurelin_shared::server::{channels::AfterAuthChannel, messages::AfterAuth};
use naia_bevy_client::{
    events::{ConnectEvent, DisconnectEvent, RejectEvent},
    events::{ConnectEvent, DisconnectEvent, MessageEvents, RejectEvent},
    Client,
};

use crate::plugins::menu::{
    ui::connect::{ConnectScreenData, ConnectState},
    MenuState,
use crate::{
    cfg::CfgUser,
    plugins::menu::{
        ui::connect::{ConnectScreenData, ConnectState},
        MenuState,
    },
};

pub fn connect_events(


@@ 52,3 56,13 @@ pub fn disconnect_events(mut ev: EventReader<DisconnectEvent>) {
        info!("Laurelin client disconnected from server.");
    }
}

pub fn message_events(mut ev: EventReader<MessageEvents>, mut cfg_user: ResMut<CfgUser>) {
    for events in ev.iter() {
        for aa_message in events.read::<AfterAuthChannel, AfterAuth>() {
            // TODO: move handling to a separate function?
            cfg_user.username = aa_message.username;
            cfg_user.cookie = aa_message.cookie;
        }
    }
}