Skip to content

Commit

Permalink
fixup! feat: reconnect after a connection is lost
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas authored and sxyazi committed Jun 14, 2024
1 parent 8b9ed5e commit 2d3cd4d
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions yazi-dds/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ impl Client {
/// If a server is closed, attempt to reconnect forever.
pub async fn echo_events_to_stdout(kinds: HashSet<String>) -> Result<()> {
let mut lines = Self::connect_listener(&kinds).await?;
let mut msg_counter = 0;

loop {
println!("Waiting for messages...");
match lines.next_line().await {
Ok(Some(s)) => {
println!("Received: message {} '{}'", msg_counter, s);
msg_counter += 1;
let kind = s.split(',').next();
if matches!(kind, Some(kind) if kinds.contains(kind)) {
println!("{}", s);
Expand All @@ -87,11 +83,9 @@ impl Client {
match Self::connect_listener(&kinds).await {
Ok(new_lines) => {
lines = new_lines;
println!("Reconnected");
break;
}
Err(_) => {
println!("Reconnecting...");
time::sleep(time::Duration::from_secs(1)).await;
}
};
Expand Down

0 comments on commit 2d3cd4d

Please sign in to comment.