diff --git a/src/cord.rs b/src/cord.rs index e72b87c9..9b43a351 100644 --- a/src/cord.rs +++ b/src/cord.rs @@ -37,13 +37,14 @@ pub struct Cord { impl Cord { pub fn new(config: Config) -> crate::Result { let (tx, rx) = mpsc::channel::(); + let session_manager = SessionManager::default(); let rich_client = Arc::new(RichClient::connect(config.client_id)?); let server = PipeServer::new(&config.pipe_name, tx.clone()); let logger = Logger::new(tx.clone(), LogLevel::Off); Ok(Self { config, - session_manager: SessionManager::new(), + session_manager, rich_client, pipe: server, tx, diff --git a/src/session/mod.rs b/src/session/mod.rs index 5cafa18a..8531c929 100644 --- a/src/session/mod.rs +++ b/src/session/mod.rs @@ -71,19 +71,13 @@ impl<'a> std::ops::DerefMut for SessionRefMut<'a> { } } +#[derive(Default)] pub struct SessionManager { sessions: RwLock>, default_config: Option, } impl SessionManager { - pub fn new() -> Self { - Self { - sessions: RwLock::new(HashMap::new()), - default_config: None, - } - } - pub fn create_session(&self, id: u32) { let mut sessions = self.sessions.write().unwrap(); let session = Session::new(id);