Skip to content

Commit

Permalink
feat(all): integrated game RPC support!
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Sep 14, 2023
1 parent 4f6cdc1 commit 90d1b7b
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 4 deletions.
133 changes: 132 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ urlencoding = "2.1.3"
# launch on startup
auto-launch = "0.5.0"

# rpc server
rsrpc = { git = "https://www.github.com/SpikeHD/rsRPC" }

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
webkit2gtk = "0.18.2"

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub fn get_streamer_mode_detection() -> bool {
parsed.streamer_mode_detection.unwrap_or(false)
}

pub fn _get_rpc_server() -> bool {
pub fn get_rpc_server() -> bool {
let parsed: Config =
serde_json::from_str(read_config_file().as_str()).unwrap_or_else(|_| default_config());
parsed.rpc_server.unwrap_or(false)
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/functionality/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod streamer_mode;
pub mod rpc;
12 changes: 12 additions & 0 deletions src-tauri/src/functionality/rpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use rsrpc::RPCServer;

pub fn start_rpc_server() {
let detectable = reqwest::blocking::get("https://raw.githubusercontent.com/OpenAsar/arrpc/main/src/process/detectable.json").unwrap().text().unwrap();

// This accepts both a `&str` or a `String`
let mut server = RPCServer::from_json_str(detectable);

server.process_scan_ms = Some(100);

server.start();
}
14 changes: 12 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,18 @@ fn main() {

// Safemode check
let safemode = std::env::args().any(|arg| arg == "--safemode");

println!("Safemode enabled: {}", safemode);

// Begin the RPC server
let rpc_thread = std::thread::spawn(|| {
if !config::get_rpc_server() {
return;
}

println!("Starting RPC server...");
functionality::rpc::start_rpc_server();
});

// Begin the proxy server
let proxy_thread = std::thread::spawn(|| block_on(proxy_server::start_server(8678)));

Expand Down Expand Up @@ -238,7 +247,8 @@ fn main() {
.run(context)
.expect("error while running tauri application");

// Join the proxy thread
// Join threads
rpc_thread.join().unwrap();
proxy_thread.join().unwrap();
}

Expand Down

0 comments on commit 90d1b7b

Please sign in to comment.