2

I want to catch when any event, regardless of the name was sent from a socket. Is there some sort of wildcard I can use here for that?

io.on('connection', function (socket) {
    socket.on('any event', function (data) {
        ...
    });
});
Darren
  • 1,774
  • 4
  • 21
  • 32
  • 1
    possible duplicate of [Socket.io Client: respond to all events with one handler?](http://stackoverflow.com/questions/10405070/socket-io-client-respond-to-all-events-with-one-handler) – Zachary Kuhn Aug 01 '15 at 01:20

2 Answers2

2

you can use the wildcard plugin to listen to all events

http://socket.io/docs/faq/ https://github.com/hden/socketio-wildcard

curiousgeorge
  • 232
  • 1
  • 6
1

u can use

socket.onAny((eventName, args...)=>{
//something
});

https://socket.io/docs/v4/listening-to-events/#socketonanylistener