add moreeeeeeeee

This commit is contained in:
shenjack-5600u 2024-02-09 14:16:49 +08:00
parent 87e6864712
commit b97f7b4332
Signed by: shenjack
GPG Key ID: FDF9864E11C7E79F
2 changed files with 19 additions and 12 deletions

View File

@ -12,3 +12,6 @@ rust_socketio = { path = "D:/githubs/rust-socketio/socketio", features = ["async
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.112" serde_json = "1.0.112"
toml = "0.8.8" toml = "0.8.8"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["time"] }

View File

@ -1,6 +1,12 @@
use rust_socketio::{Payload, RawClient}; use rust_socketio::{Payload, RawClient, Event};
fn main() { fn main() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.init();
// 从命令行读取配置文件路径 // 从命令行读取配置文件路径
let args: Vec<String> = std::env::args().collect(); let args: Vec<String> = std::env::args().collect();
if args.len() != 2 { if args.len() != 2 {
@ -19,17 +25,13 @@ fn main() {
); );
let socket = rust_socketio::ClientBuilder::new(url) let socket = rust_socketio::ClientBuilder::new(url)
.on("connect", |args, _| { .transport_type(rust_socketio::TransportType::Websocket)
println!("Connected: {:?}", args); .on_any(|event: Event, payload: Payload, _: RawClient| {
println!("Received event: {:?} with payload: {:?}", event, payload);
}) })
.on("event", |args, _| { .on("error", |err, _: RawClient| {
println!("Event: {:?}", args); println!("Received error: {:?}", err);
}) // panic!("Error received from server {:?}", err);
.on("disconnect", |args, _| {
println!("Disconnected: {:?}", args);
})
.on("error", |args, _| {
println!("Error!!: {:?}", args);
}) })
.connect() .connect()
.unwrap(); .unwrap();
@ -46,7 +48,9 @@ fn main() {
std::time::Duration::from_secs(10), std::time::Duration::from_secs(10),
request_callback, request_callback,
); );
println!("Request result: {:?}", res);
let empty: Vec<u8> = vec![];
socket.emit("request-cert", Payload::from(empty)).unwrap();
std::thread::sleep(std::time::Duration::from_secs(20)); std::thread::sleep(std::time::Duration::from_secs(20));
} }