anonymous calls
This commit is contained in:
parent
309342b730
commit
8747657999
12 changed files with 712 additions and 39 deletions
21
src/anonymous_clients/anonymous_manager.rs
Normal file
21
src/anonymous_clients/anonymous_manager.rs
Normal 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())
|
||||
}
|
||||
Loading…
Reference in a new issue