Skip to content

Instantly share code, notes, and snippets.

@mexus
Created August 1, 2018 20:26
Show Gist options
  • Save mexus/19f7d6d49e552ef944d1d2428b0d279c to your computer and use it in GitHub Desktop.
Save mexus/19f7d6d49e552ef944d1d2428b0d279c to your computer and use it in GitHub Desktop.
diff --git a/src/main.rs b/src/main.rs
index b43471a..9a015a6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -127,7 +127,7 @@ fn init_ws(r: &Client, &conn: &Connection, url: &str) {
sink.send(Message::Text(subscribe.to_string()))
.map_err(FHError::Send)
- .and_then(|_| {
+ .and_then(|sink| {
println!("subscribe sent: {}", subscribe);
let q_insert = r.db(DB).table(TBL);
@@ -145,14 +145,11 @@ fn init_ws(r: &Client, &conn: &Connection, url: &str) {
let timer_ping = Interval::new(Instant::now(), Duration::from_secs(2))
.map_err(FHError::Timer)
- .for_each(move |_| {
- // sink.send(Message::Ping(vec![1]))
- // .map_err(FHError::Send)
- // .and_then(|_| {
- println!("ping");
- Ok(())
- // })
- });
+ .and_then(|_| Ok(Message::Ping(vec![1])));
+ let timer_ping = sink
+ .sink_map_err(FHError::Send)
+ .send_all(timer_ping)
+ .map(|_| ());
let flow = stream.map_err(FHError::Read).for_each(move |msg| {
let mut json: Value =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment