#[cfg(not(target_arch = "wasm32"))] use { clap::{App, Arg}, mio_license::MioWebSocketSend, }; #[cfg(not(target_arch = "wasm32"))] #[tokio::main] async fn main() { simple_logger::init_with_level(log::Level::Info).unwrap(); let matches = App::new("Media-IO Validate") .version("1.0") .author("Marc-Antoine Arnaud ") .about("Validate Media-IO license") .arg( Arg::with_name("signer-url") .long("signer-url") .value_name("SIGNER_URL") .default_value("http://localhost:8000") .help("Sets the Signer server URL (default: http://localhost:8000"), ) .arg( Arg::with_name("token") .long("token") .value_name("TOKEN") .help("Sets the token (in JWT format)") .required(true), ) .arg( Arg::with_name("product") .long("product") .value_name("PRODUCT") .help("Sets the product to validate") .required(true), ) .get_matches(); let signer_url = matches.value_of("signer-url").unwrap(); let token = matches.value_of("token").unwrap(); let product = matches.value_of("product").unwrap(); let response = mio_license::validate(token, product, signer_url).await; if let Err(message) = response { panic!("NOT VALID LICENSE: {:?}", message); } let (claims, mut ws_stream) = response.unwrap(); println!("{:?}", claims); loop { // do some stuff here std::thread::sleep(std::time::Duration::from_secs(30)); let payload = "{}".to_string(); ws_stream = ws_stream.send(payload); } } #[cfg(target_arch = "wasm32")] fn main() { println!("Validate application not available for WebAssembly target"); }