switch to default iris app

This commit is contained in:
2025-12-04 14:31:34 -05:00
parent 1904560244
commit 02696b1f75
10 changed files with 61 additions and 528 deletions

View File

@@ -1,4 +1,4 @@
use crate::{AppHandle, ClientEvent};
use crate::ClientEvent;
use openworm::net::{
ClientMsg, RecvHandler, SERVER_NAME, ServerMsg, SkipServerVerification, recv_uni, send_uni,
};
@@ -13,6 +13,7 @@ use std::{
time::Duration,
};
use tokio::sync::mpsc::UnboundedSender;
use winit::{event_loop::EventLoopProxy, window::Window};
pub const CLIENT_SOCKET: SocketAddr =
SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, 0, 0, 0));
@@ -26,6 +27,19 @@ pub struct NetHandle {
pub thread: JoinHandle<()>,
}
#[derive(Clone)]
pub struct AppHandle {
pub proxy: EventLoopProxy<ClientEvent>,
pub window: Arc<Window>,
}
impl AppHandle {
pub fn send(&self, event: ClientEvent) {
self.proxy.send_event(event).unwrap_or_else(|_| panic!());
self.window.request_redraw();
}
}
pub fn connect(handle: AppHandle, info: ConnectInfo) -> JoinHandle<()> {
std::thread::spawn(move || {
if let Err(msg) = connect_the(handle.clone(), info) {