[Add] basic Tauri
This commit is contained in:
parent
f23bd4cfef
commit
9904e54914
8 changed files with 261 additions and 55 deletions
|
|
@ -3,6 +3,7 @@ use dashmap::DashMap;
|
|||
use once_cell::sync::Lazy;
|
||||
use rand::prelude::IteratorRandom;
|
||||
use std::sync::Arc;
|
||||
use ttp_core::CommunicationValue;
|
||||
|
||||
pub static OMIKRON_CONNECTIONS: Lazy<DashMap<i64, Arc<OmikronConnection>>> =
|
||||
Lazy::new(|| DashMap::new());
|
||||
|
|
@ -24,6 +25,7 @@ pub async fn add_omikron(conn: Arc<OmikronConnection>) {
|
|||
pub async fn remove_omikron(omikron_id: i64) {
|
||||
OMIKRON_CONNECTIONS.remove(&omikron_id);
|
||||
}
|
||||
|
||||
pub async fn get_random_omikron() -> Result<Arc<OmikronConnection>, ()> {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
|
|
@ -37,3 +39,11 @@ pub async fn get_random_omikron() -> Result<Arc<OmikronConnection>, ()> {
|
|||
|
||||
Err(())
|
||||
}
|
||||
|
||||
pub async fn send_to_user(user_id: i64, cv: &CommunicationValue) {
|
||||
if let Some(user_conn) = crate::sql::user_online_tracker::get_user_status(user_id) {
|
||||
if let Some(omikron_conn) = OMIKRON_CONNECTIONS.get(&user_conn.omikron_id) {
|
||||
let _ = omikron_conn.value().clone().send_message(cv).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue