It seems that the ack functions for responding to the packet ID are missing in both synchronous and asynchronous versions when the emitWithAck function is called from another side.
I noticed that acknowledgment (ack) functionality for handling packet responses is missing, unlike Node.js where callback-style ack functions are commonly used. Therefore, I believe we need to implement a separate ack function to provide similar functionality.
use rust_socketio::{ClientBuilder, Payload, RawClient};
use std::{thread::sleep, time::Duration};
fn main() {
let callback = |payload: Payload, socket: RawClient| {
match payload {
#![allow(deprecated)]
Payload::String(str) => println!("Received: {}", str),
Payload::Binary(bin_data) => println!("Received bytes: {:#?}", bin_data),
Payload::Text(vec) => println!("Received text: {:#?}", vec),
}
///missing ack function like below : there is no way to respond
socket.ack("ack resend").expect("Server unreachable");
};
// get a socket that is connected to the admin namespace
let socket = ClientBuilder::new("http://localhost:3000")
//.namespace("/admin")
.on("test", callback)
.on("error", |err, _| eprintln!("Error: {:#?}", err))
.connect()
.expect("Connection failed");
sleep(Duration::from_secs(5));
socket.disconnect().expect("Disconnect failed");
println!("disconnected waiting completed");
}
It seems that the ack functions for responding to the packet ID are missing in both synchronous and asynchronous versions when the emitWithAck function is called from another side.
I noticed that acknowledgment (ack) functionality for handling packet responses is missing, unlike Node.js where callback-style ack functions are commonly used. Therefore, I believe we need to implement a separate ack function to provide similar functionality.