rust-socketio
rust-socketio copied to clipboard
Emit with multiple parameters
The Client.emit and Client.emit_with_ack only seem to support a single data parameter
This causes issues for servers who are expecting multiple parameters for the data for these events
rust.rs
socket.emit_with_ack("foo", json!("{ack:true}", duration, callback)
example_socketio_server.js
socket.on("foo", async (userId, body, callback)=>{})
no mater what is placed in data, it will place all data under the "userId" and no way to populate the body parameter.
Is there a workaround that could fix this?
Do you use a special parser for this on the server side?
No. We don't use any parser beyond the default behavior of the nodejs package server-side.
const io = socketio(server, { path: '/socket', transports: ['websocket'] })
As seen here the emit function takes an unbound number of arguments. This behavior is handled server side as per this example
@david-sailplan https://github.com/1c3t3a/rust-socketio/blob/4ac27c7158a89375c503164857d86b1a1167116c/socketio/src/socket.rs#L105-L109 currently is limit to only two params, L108 accept a string, so there is a tricky way socket .emit("foo", "bar1\",\"bar2\", \"bar3")
, you can have a try.
@SSebo is there currently a better way to do this using "binary data/attachments"?
I know your todo list is probably long, but a proper interface for encoding multiple message parameters would be a great feature :)
@SSebo is there currently a better way to do this using "binary data/attachments"?
I know your todo list is probably long, but a proper interface for encoding multiple message parameters would be a great feature :)
@1c3t3a @nshaaban-cPacket they are the owners of this repo, I forward your message to them :)
#249 I made a PR @david-sailplan @syshriki9 You can have a try.
Wow that was fast!, Thanks @SSebo.
As David mentioned, it seems to work.
@SSebo @1c3t3a do you guys think this feature will make it into the master?
also. that……
hmmm
well, now the .on
can not accept mult payload, so ……
anther old issue
This issue is mostly done, likely able to close