Closed emmtte closed 4 years ago
It needs to import AtomicBool, see below
extern crate binance;
use binance::websockets::*;
use std::sync::atomic::{AtomicBool};
fn main() {
let keep_running = AtomicBool::new(true); // Used to control the event loop
let kline: String = format!("{}", "ethbtc@kline_1m");
let mut web_socket: WebSockets = WebSockets::new(|event: WebsocketEvent| { match event {
WebsocketEvent::Kline(kline_event) => {
println!(
"Symbol: {}, high: {}, low: {}",
kline_event.kline.symbol, kline_event.kline.low, kline_event.kline.high
);
},
_ => (),
}; Ok(())
});
web_socket.connect(&kline).unwrap(); // check error
if let Err(e) = web_socket.event_loop(&keep_running) {
match e {
err => {
println!("Error: {}", err);
}
}
}
web_socket.disconnect().unwrap();
}
For more examples, see https://github.com/wisespace-io/binance-rs/blob/master/examples/binance_websockets.rs
Thanks @wisespace-io, work like as expected
Hi, I follow your exemple code for websocket kindle and have an error
Error :