add read-timeout to client
This commit is contained in:
parent
4a4b0a3343
commit
ecdfd589fa
1 changed files with 10 additions and 1 deletions
11
src/main.rs
11
src/main.rs
|
@ -127,6 +127,13 @@ impl OptAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_server_command(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
OptAction::OpenWindow { .. } => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_main() -> Result<()> {
|
fn try_main() -> Result<()> {
|
||||||
|
@ -137,6 +144,7 @@ fn try_main() -> Result<()> {
|
||||||
stream.write_all(&bincode::serialize(&opts)?)?;
|
stream.write_all(&bincode::serialize(&opts)?)?;
|
||||||
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
|
stream.set_read_timeout(Some(std::time::Duration::from_millis(100)))?;
|
||||||
stream.read_to_string(&mut buf)?;
|
stream.read_to_string(&mut buf)?;
|
||||||
println!("{}", buf);
|
println!("{}", buf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,7 +162,8 @@ fn try_main() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_server(opts: Opt) -> Result<()> {
|
fn initialize_server(opts: Opt) -> Result<()> {
|
||||||
if opts.action == OptAction::KillServer {
|
if opts.action == OptAction::KillServer || !opts.action.is_server_command() {
|
||||||
|
println!("No eww server running");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue