Skip to content

Commit

Permalink
Remove duplicate code (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
feschber authored Dec 27, 2023
1 parent 5c152b0 commit 9c0cc98
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,44 +720,12 @@ impl Server {
}
}

#[cfg(unix)]
async fn handle_frontend_stream(
client_manager: &Rc<RefCell<ClientManager>>,
frontend: &mut FrontendListener,
frontend_tx: &Sender<FrontendEvent>,
mut stream: ReadHalf<UnixStream>,
) {
use std::io;

let tx = frontend_tx.clone();
tokio::task::spawn_local(async move {
loop {
let event = frontend::read_event(&mut stream).await;
match event {
Ok(event) => {
let _ = tx.send(event).await;
}
Err(e) => {
if let Some(e) = e.downcast_ref::<io::Error>() {
if e.kind() == ErrorKind::UnexpectedEof {
return;
}
}
log::error!("error reading frontend event: {e}");
return;
}
}
}
});
Self::enumerate(client_manager, frontend).await;
}

#[cfg(windows)]
async fn handle_frontend_stream(
client_manager: &Rc<RefCell<ClientManager>>,
frontend: &mut FrontendListener,
frontend_tx: &Sender<FrontendEvent>,
mut stream: ReadHalf<TcpStream>,
#[cfg(unix)] mut stream: ReadHalf<UnixStream>,
#[cfg(windows)] mut stream: ReadHalf<TcpStream>,
) {
use std::io;

Expand Down

0 comments on commit 9c0cc98

Please sign in to comment.