From 1d05a7394e5cf72538cc79b22c5f9330f179cfc3 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sun, 23 Feb 2025 17:37:39 +0100 Subject: move network config to it's own file and impl it's sync --- src/session/mod.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/session') diff --git a/src/session/mod.rs b/src/session/mod.rs index dbe29c0..f98cd04 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -5,7 +5,7 @@ use crate::message::StatefulSyncableClient; #[cfg(feature = "server")] use crate::message::StatefulSyncableServer; -use log::{debug, warn}; +use log::{debug, error, warn}; use crate::message::{ objects::{Types, *}, @@ -26,6 +26,7 @@ pub struct Session { pub identities: Vec, pub ignore_list_manager: IgnoreListManager, pub networks: HashMap, + pub network_config: NetworkConfig, } /// The Session Trait is the main point of entry and implements the basic logic @@ -42,6 +43,7 @@ pub trait SessionManager { fn ignore_list_manager(&mut self) -> &mut IgnoreListManager; fn networks(&mut self) -> &mut HashMap; fn network(&mut self, id: i32) -> Option<&mut Network>; + fn network_config(&mut self) -> &mut NetworkConfig; fn sync(&mut self, msg: SyncMessage) where @@ -65,7 +67,13 @@ pub trait SessionManager { } } Class::NetworkInfo => (), - Class::NetworkConfig => (), + Class::NetworkConfig => match msg.object_name.as_ref() { + "GlobalNetworkConfig" => self.network_config().sync(msg), + _ => error!( + "received network config sync with unknown object name: {}", + msg.object_name + ), + }, Class::IrcChannel => { let mut object_name = msg.object_name.split('/'); let network_id: i32 = object_name.next().unwrap().parse().unwrap(); @@ -196,4 +204,8 @@ impl SessionManager for Session { fn network(&mut self, id: i32) -> Option<&mut Network> { self.networks.get_mut(&id) } + + fn network_config(&mut self) -> &mut NetworkConfig { + &mut self.network_config + } } -- cgit v1.2.3