This commit is contained in:
2026-04-22 19:04:22 +02:00
parent 23dab2df85
commit f073b14e01
18 changed files with 1072 additions and 180 deletions

View File

@@ -9,8 +9,9 @@
#![deny(unreachable_pub)]
#![warn(missing_docs)]
mod splash;
mod demo_http;
mod demo_ws;
mod splash;
pub use crate::splash::SplashOrder;
use tauri::Emitter;
@@ -36,6 +37,7 @@ struct KbAppState {
config: kb_lib::KbConfig,
ws_runtime: tokio::sync::Mutex<KbWsRuntimeState>,
demo_ws_runtime: std::sync::Arc<tokio::sync::Mutex<crate::demo_ws::KbDemoWsRuntimeState>>,
http_pool: kb_lib::HttpEndpointPool,
}
/// Runs the desktop application.
@@ -72,12 +74,21 @@ pub fn run() {
environment = %config.app.environment,
"starting desktop application"
);
let http_pool_result = kb_lib::HttpEndpointPool::from_config(&config);
let http_pool = match http_pool_result {
Ok(http_pool) => http_pool,
Err(error) => {
tracing::error!("cannot create http endpoint pool: {}", error);
panic!("cannot create http endpoint pool: {}", error);
}
};
let app_state = KbAppState {
config: config.clone(),
ws_runtime: tokio::sync::Mutex::new(KbWsRuntimeState::new()),
demo_ws_runtime: std::sync::Arc::new(tokio::sync::Mutex::new(
crate::demo_ws::KbDemoWsRuntimeState::new(),
)),
http_pool,
};
let tracing_builder = tauri_plugin_tracing::Builder::new();
let mut tauri_builder = tauri::Builder::default();
@@ -91,7 +102,10 @@ pub fn run() {
crate::demo_ws::demo_ws_connect,
crate::demo_ws::demo_ws_disconnect,
crate::demo_ws::demo_ws_subscribe,
crate::demo_ws::demo_ws_unsubscribe_current
crate::demo_ws::demo_ws_unsubscribe_current,
crate::demo_http::open_demo_http_window,
crate::demo_http::demo_http_list_pool_clients,
crate::demo_http::demo_http_execute_request,
]);
tauri_builder = tauri_builder.plugin(tracing_builder.build::<tauri::Wry>());
tauri_builder = tauri_builder.setup(|app| {
@@ -147,7 +161,7 @@ pub fn run() {
emit_splash_order(&splash_window, "fadeout", None, None);
tracing::debug!("end splash fadeout");
tokio::time::sleep(std::time::Duration::from_millis(3100)).await;
let close_result = splash_window.close();
let close_result = splash_window.destroy();
if let Err(error) = close_result {
tracing::error!("error closing splash window: {error:?}");
}
@@ -351,13 +365,13 @@ fn kb_format_ws_event(event: &kb_lib::WsEvent) -> std::string::String {
endpoint_url,
} => {
format!("[ws:{endpoint_name}] connected to {endpoint_url}")
},
}
kb_lib::WsEvent::TextMessage {
endpoint_name,
text,
} => {
format!("[ws:{endpoint_name}] text: {text}")
},
}
kb_lib::WsEvent::JsonRpcMessage {
endpoint_name,
message,