[feat] use eti game.db, commit not working, something is wrong with game.id in the client/frontend

This commit is contained in:
2024-11-12 22:12:49 +01:00
parent ba2177abf0
commit 1388bc2115
17 changed files with 790 additions and 310 deletions

View File

@ -1,4 +1,4 @@
use std::{net::SocketAddr, process::Command};
use std::net::SocketAddr;
use lanspread_client::{ClientCommand, ClientEvent};
use lanspread_mdns::{discover_service, LANSPREAD_INSTANCE_NAME, LANSPREAD_SERVICE_TYPE};
@ -22,24 +22,26 @@ fn request_games(state: tauri::State<LanSpreadState>) {
}
#[tauri::command]
fn run_game_backend(id: u64, state: tauri::State<LanSpreadState>) -> String {
fn run_game_backend(id: String, state: tauri::State<LanSpreadState>) -> String {
log::error!("Running game with id {id}");
let result = Command::new(r#"C:\Users\ddidderr\scoop\apps\mpv\0.39.0\mpv.exe"#).spawn();
// let result = Command::new(r#"C:\Users\ddidderr\scoop\apps\mpv\0.39.0\mpv.exe"#).spawn();
if let Err(e) = state.inner().client_ctrl.send(ClientCommand::GetGame(id)) {
log::error!("Failed to send message to client: {e:?}");
}
if result.is_ok() {
"Ok".to_string()
} else {
"Failed to run game".to_string()
}
"TODO".to_string()
// if result.is_ok() {
// "Ok".to_string()
// } else {
// "Failed to run game".to_string()
// }
}
async fn find_server(app: AppHandle) {
log::error!("Looking for server...");
log::info!("Looking for server...");
loop {
match discover_service(LANSPREAD_SERVICE_TYPE, Some(LANSPREAD_INSTANCE_NAME)) {
@ -73,7 +75,7 @@ pub fn run() {
tauri_plugin_log::TargetKind::Stdout,
))
.level(log::LevelFilter::Info)
.level_for("lanspread_client", log::LevelFilter::Debug)
.level_for("lanspread_client", log::LevelFilter::Trace)
.level_for("lanspread_tauri_leptos_lib", log::LevelFilter::Debug)
.level_for("mdns_sd::service_daemon", log::LevelFilter::Off);
@ -106,7 +108,7 @@ pub fn run() {
let app_handle = app.handle().clone();
tauri::async_runtime::spawn(async move {
while let Some(event) = rx_client_event.recv().await {
log::debug!("Received client event: {event:?}");
log::debug!("Received client event");
match event {
ClientEvent::ListGames(games) => {