can i use socketio as multiple callback? #5302
Unanswered
JongHyeonSong
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi! Yes it can work, you're just missing to set a timeout value: socket.on("cli-offer", (data, cb1) => {
function cb2(err, responses) {
console.log("🚀 ~ SocketIoService ~ cb2 ~ res:", responses[0]);
// BELLOW IS ERROR
// Error: operation has timed out
// at Timeout._onTimeout (C:\Users\user\Desktop\project\company\new-kiosk-project\webrtc-peerjs\node_modules\socket.io\dist\broadcast-operator.js:182:17)
// at listOnTimeout (node:internal/timers:559:17)
// at processTimers (node:internal/timers:502:7)
cb1(responses[0]);
}
socket.timeout(5000).to(target1).emit("srv-offer", { offer }, cb2);
// socket.emit("srv-offer", { offer }, cb2); // it works
}); Please be aware that the arguments of
Reference: https://socket.io/docs/v4/emit-cheatsheet/#acknowledgements |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
below is some part nodejs server code
1way callback works well client->server, server-> client
but 2way seem not work, erorr go out immediatly. (but it is weired if re-emit to himself, it works...)
wanna know if it is not work theoreticaly or not
Beta Was this translation helpful? Give feedback.
All reactions