#![feature(stmt_expr_attributes, proc_macro_hygiene)] extern crate futures; extern crate futures_async_stream; extern crate pretty_env_logger; extern crate tokio; extern crate cxmr_currency; extern crate cxmr_ws_client; extern crate cxmr_ws_client_poloniex; use std::time::Duration; use futures::channel::mpsc::unbounded; use futures_async_stream::for_await; use cxmr_currency::CurrencyPair; use cxmr_ws_client::{subscribe, Subscription}; use cxmr_ws_client_poloniex::PoloniexPublicProtocol; #[tokio::main] pub async fn main() -> Result<(), Box> { pretty_env_logger::init(); let sub = Subscription::Pairs(vec![CurrencyPair::AdaBtc, CurrencyPair::EthBtc]); let (tx, rx) = unbounded(); // spawn_reconnecting_feed() tokio::spawn(async move { loop { println!("subscribe"); let _ = subscribe::(&sub, tx.clone()).await; println!("delay_for"); tokio::time::delay_for(Duration::from_secs(10)).await; } }); #[for_await] for ev in rx { println!( "exchange: {:?} pair: {:?} events: {:?}", ev.market.exchange(), ev.market.currency_pair().as_str(), ev.events ); } Ok(()) }