anonymous calls

This commit is contained in:
Alex-Emmet 2026-01-20 21:45:05 +01:00
commit 8747657999
12 changed files with 712 additions and 39 deletions

View file

@ -0,0 +1,21 @@
use std::sync::Arc;
use dashmap::DashMap;
use once_cell::sync::Lazy;
use crate::anonymous_clients::anonymous_client_connection::AnonymousClientConnection;
static ANONYMOUS_USERS: Lazy<DashMap<i64, Arc<AnonymousClientConnection>>> =
Lazy::new(|| DashMap::new());
pub async fn add_anonymous_user(connection: Arc<AnonymousClientConnection>) {
ANONYMOUS_USERS.insert(connection.get_user_id().await, connection);
}
pub async fn remove_anonymous_user(user_id: i64) {
ANONYMOUS_USERS.remove(&user_id);
}
pub async fn get_anonymous_user(user_id: i64) -> Option<Arc<AnonymousClientConnection>> {
ANONYMOUS_USERS.get(&user_id).map(|c| c.clone())
}