socket.io
socket.io copied to clipboard
Ack emit is not propagated through onAnyOutgoing
Describe the bug Ack emit is not propagated through onAnyOutgoing.
To Reproduce
Socket.IO server version: latest
Server
import { Server } from "socket.io";
const io = new Server(3000, {});
io.on("connection", (socket) => {
console.log(`connect ${socket.id}`);
socket.use((event) => {
console.log(event) // not logger for "test msg"
})
socket.on('msg', (reply) => {
reply('test msg')
})
socket.on("disconnect", () => {
console.log(`disconnect ${socket.id}`);
});
});
Socket.IO client version: latest
Client
import { io } from "socket.io-client";
const socket = io("ws://localhost:3000/", {});
socket.on("connect", () => {
console.log(`connect ${socket.id}`);
});
socket.emit("msg")
socket.on("disconnect", () => {
console.log("disconnect");
});
Expected behavior
onAnyOutgoing is called for ANY outgoing message
Hi! You are right, onAnyOutgoing (like onAny) does not currently catch acknowledgements.
I'm open to suggestions on this, either a new API, or by reusing onAnyOutgoing (though acknowledgements don't have an event name).
Wouldnt the event name be the same as the incoming one?
client -> "event-1" -> server
server -> ack of "event-1" -> client