split 2 of 772644f, debugging ci

This commit is contained in:
17ms 2023-05-01 16:34:53 +03:00
parent f8e2806406
commit e1af665a65

View File

@ -184,28 +184,49 @@ impl Connector {
) -> Result<(), Box<dyn Error + Send + Sync>> { ) -> Result<(), Box<dyn Error + Send + Sync>> {
loop { loop {
let rx_msg = rx.recv().await; let rx_msg = rx.recv().await;
if rx_msg.is_none() {
continue;
}
match rx_msg.unwrap() { match self.msg_handler(rx_msg.unwrap(), conn, metadata).await {
Message::ClientReq(name) => { Ok(true) => continue,
let req = Request::new(name, metadata).unwrap(); // TODO: handle Ok(false) => break,
self.request(conn, req).await?; Err(e) => return Err(e),
}
Message::Shutdown => {
let msg = b"DISCONNECT".to_vec();
comms::send(
&mut conn.writer,
Some(&mut conn.cipher),
Some(&mut conn.rng),
&msg,
)
.await?;
break;
}
_ => continue,
} }
} }
Ok(()) Ok(())
} }
async fn msg_handler(
&self,
msg: Message,
conn: &mut Connection<'_>,
metadata: &HashMap<String, (u64, String)>,
) -> Result<bool, Box<dyn Error + Send + Sync>> {
match msg {
Message::ClientReq(name) => {
let req = match Request::new(name, metadata) {
Some(req) => req,
None => return Ok(true),
};
self.request(conn, req).await?;
Ok(true)
}
Message::Shutdown => {
let msg = b"DISCONNECT".to_vec();
comms::send(
&mut conn.writer,
Some(&mut conn.cipher),
Some(&mut conn.rng),
&msg,
)
.await?;
Ok(false)
}
_ => Ok(true),
}
}
} }