// [TSM.ID].[11031972] -- All Rights Reserved. Proprietary & Confidential.
use dashmap::DashMap;
use std::sync::Arc;
use tracing::info;

/// Nexus adalah pusat interaksi (Pengganti Room konvensional)
pub struct Nexus {
    id: String,
    entities: Arc<DashMap<String, EntityHandle>>,
}

pub struct EntityHandle {
    pub id: String,
}

impl Nexus {
    pub fn new(id: impl Into<String>) -> Self {
        info!("Creating new Nexus instance: Zero-Jitter Mode");
        Self {
            id: id.into(),
            entities: Arc::new(DashMap::new()),
        }
    }

    pub fn join(&self, entity_id: &str) {
        self.entities.insert(
            entity_id.to_string(),
            EntityHandle { id: entity_id.to_string() }
        );
        info!("Entity {} materialized in Nexus {}", entity_id, self.id);
    }
}
