Skip to content

Commit

Permalink
cli: wait for connection (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
feschber committed Dec 19, 2023
1 parent 015face commit d9fa86e
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/frontend/cli.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
use anyhow::{anyhow, Context, Result};
#[cfg(windows)]
use std::net::SocketAddrV4;

use std::{
io::{ErrorKind, Read, Write},
str::SplitWhitespace,
thread,
};

#[cfg(windows)]
use std::net::TcpStream;
#[cfg(unix)]
use std::os::unix::net::UnixStream;

use crate::{client::Position, config::DEFAULT_PORT};

use super::{FrontendEvent, FrontendNotify};

pub fn run() -> Result<()> {
#[cfg(unix)]
let socket_path = super::FrontendListener::socket_path()?;

#[cfg(unix)]
let Ok(mut tx) = UnixStream::connect(socket_path) else {
return Err(anyhow!("Could not connect to lan-mouse-socket"));
};

#[cfg(windows)]
let Ok(mut tx) = TcpStream::connect("127.0.0.1:5252".parse::<SocketAddrV4>().unwrap()) else {
let Ok(mut tx) = super::wait_for_service() else {
return Err(anyhow!("Could not connect to lan-mouse-socket"));
};

Expand Down

0 comments on commit d9fa86e

Please sign in to comment.