Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub async fn inject(
omp_file
};

crate::ipc::ensure_listening();

match injector::run_samp(
name,
ip,
Expand Down
22 changes: 21 additions & 1 deletion src-tauri/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::io::BufRead;
use std::net::{TcpListener, TcpStream};
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, OnceLock};
use std::thread;
use tauri::{AppHandle, Manager, WindowBuilder, WindowUrl};

Expand All @@ -12,6 +13,25 @@ type SharedStreams = Arc<Mutex<HashMap<i32, TcpStream>>>;

pub static GAME_STREAMS: Lazy<SharedStreams> = Lazy::new(|| Arc::new(Mutex::new(HashMap::new())));

static IPC_HANDLE: OnceLock<AppHandle> = OnceLock::new();
static IPC_STARTED: AtomicBool = AtomicBool::new(false);

pub fn init_ipc(app_handle: AppHandle) {
let _ = IPC_HANDLE.set(app_handle);
}

pub fn ensure_listening() {
if IPC_STARTED
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.is_err()
{
return;
}
if let Some(handle) = IPC_HANDLE.get() {
listen_for_ipc(handle.clone());
}
}

fn create_overlay_window(
app: &tauri::AppHandle,
label: &str,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ fn setup_tauri_app(app: &mut tauri::App) -> std::result::Result<(), Box<dyn std:
#[cfg(windows)]
setup_deeplinks(handle.clone())?;

ipc::listen_for_ipc(handle);
ipc::init_ipc(handle);
Ok(())
}

Expand Down
Loading