Files
k-frame/crates/client-esp32/src/tasks/network.rs
Gabriel Kaszewski 7001b5e911 arch: split ConfigRepository, extract polling, consolidate conversions, decouple protocol
- Value↔JSON: From impls on domain Value behind `json` feature, delete 4 duplicate converters
- ConfigRepository split into ConfigRepository (12), UserRepository (3), WidgetStateCache (2)
- polling orchestration moved from bootstrap to application::polling_service
- WidgetRenderer in client-domain owns scroll/cache, both clients use it
- network loop consolidated into client-application::run_connection_loop
- protocol crate drops domain dep, Wire↔Domain conversions move to adapters
2026-06-19 18:12:50 +02:00

27 lines
973 B
Rust

use std::sync::mpsc;
use std::thread;
use client_application::run_connection_loop;
use super::RenderEvent;
use crate::config::{NET_THREAD_STACK_SIZE, NET_POLL_INTERVAL, NET_RECONNECT_DELAY};
use crate::adapters::network::Esp32Network;
pub fn spawn(server_addr: String, tx: mpsc::Sender<RenderEvent>) {
thread::Builder::new()
.stack_size(NET_THREAD_STACK_SIZE)
.name("net".into())
.spawn(move || {
let mut net = Esp32Network::new();
let tx_msg = tx.clone();
let tx_status = tx.clone();
run_connection_loop(
&mut net,
&server_addr,
NET_POLL_INTERVAL,
NET_RECONNECT_DELAY,
move |msg| { let _ = tx_msg.send(RenderEvent::Server(msg)); },
move |connected| { let _ = tx_status.send(RenderEvent::ConnectionStatus(connected)); },
);
})
.expect("failed to spawn network thread");
}