Skip to content

Commit

Permalink
Use add_typed_route instead of custom thread (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master authored Nov 11, 2024
1 parent 68f86f0 commit 7696ac4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/verso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,19 @@ impl Verso {
let (controller_sender, receiver) = ipc::channel::<ControllerMessage>().unwrap();
sender.send(controller_sender).unwrap();
let proxy_clone = proxy.clone();
std::thread::Builder::new()
.name("IpcMessageRelay".to_owned())
.spawn(move || {
while let Ok(message) = receiver.recv() {
ROUTER.add_typed_route(
receiver,
Box::new(move |message| match message {
Ok(message) => {
if let Err(e) =
proxy_clone.send_event(EventLoopProxyMessage::IpcMessage(message))
{
log::error!("Failed to send controller message to Verso: {e}");
}
}
})
.unwrap();
Err(e) => log::error!("Failed to receive controller message: {e}"),
}),
);
};

// Initialize configurations and Verso window
Expand Down

0 comments on commit 7696ac4

Please sign in to comment.