@@ 42,7 42,10 @@ fn main() {
// init system
.add_startup_system(systems::init::init)
// events
- .add_system(systems::event::auth_events);
+ .add_system(systems::event::auth_events)
+ .add_system(systems::event::connect_events)
+ .add_system(systems::event::disconnect_events)
+ .add_system(systems::event::error_events);
info!("Laurelin server starting");
server.run();
@@ 7,11 7,15 @@
*/
use bevy_ecs::{event::EventReader, system::Res};
+use bevy_log::info;
use laurelin_shared::{
api::user::{login, register, ResponseLogin, ResponseRegister},
server::messages::Auth,
};
-use naia_bevy_server::{events::AuthEvents, Server};
+use naia_bevy_server::{
+ events::{AuthEvents, ConnectEvent, DisconnectEvent, ErrorEvent},
+ Server,
+};
use crate::Config;
@@ 44,3 48,22 @@ pub(crate) fn auth_events(
}
}
}
+
+pub(crate) fn connect_events(mut ev: EventReader<ConnectEvent>, mut server: Server) {
+ for ConnectEvent(user_key) in ev.iter() {
+ let address = server.user(user_key).address();
+ info!("Naia Server connected to: {:?}", address);
+ }
+}
+
+pub(crate) fn disconnect_events(mut ev: EventReader<DisconnectEvent>) {
+ for DisconnectEvent(_user_key, user) in ev.iter() {
+ info!("Naia Server disconnected from: {:?}", user.address);
+ }
+}
+
+pub(crate) fn error_events(mut ev: EventReader<ErrorEvent>) {
+ for ErrorEvent(error) in ev.iter() {
+ info!("Naia Server Error: {:?}", error);
+ }
+}