[Add] basic Tauri

This commit is contained in:
Alex Emmet 2026-05-17 21:34:55 +02:00
commit 9904e54914
8 changed files with 261 additions and 55 deletions

View file

@ -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;
}
}
}