Properly await on the futures.

This commit ensures that the reader/writer on the connection workers properly
This commit is contained in:
R Tyler Croy 2020-02-01 06:29:55 -08:00
parent 477e3c7933
commit b1f5e39bf4
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
1 changed files with 8 additions and 2 deletions

View File

@ -162,6 +162,7 @@ async fn main() {
});
let index = warp::path::end().and(with_render(hb)).and_then(index);
let ws = warp::path("ws").and(warp::ws()).and(event_bus.clone()).map(
move |ws: warp::ws::Ws, bus: Arc<Bus>| {
// And then our closure will be called when it completes...
@ -205,11 +206,16 @@ impl Connection {
});
let writer = tokio::task::spawn(async {
info("writier!");
/*
* NOTE: we need to wait for messages to come in on some channel here?
* busy loop
*/
info!("writer!");
future::ready(())
});
future::join(reader, writer)
// TODO handle errors on the join
future::join(reader, writer).await;
}
}