socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Ack emit is not propagated through onAnyOutgoing

Open alesmenzel opened this issue 3 years ago • 2 comments

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

alesmenzel avatar Oct 06 '22 15:10 alesmenzel

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).

darrachequesne avatar Oct 08 '22 08:10 darrachequesne

Wouldnt the event name be the same as the incoming one?

client -> "event-1" -> server
server -> ack of "event-1" -> client

alesmenzel avatar Nov 01 '22 10:11 alesmenzel