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) {
...
});
});
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) {
...
});
});
Share
Improve this question
asked Aug 1, 2015 at 0:59
DarrenDarren
1,9945 gold badges23 silver badges35 bronze badges
1
- 1 possible duplicate of Socket.io Client: respond to all events with one handler? – Zachary Kuhn Commented Aug 1, 2015 at 1:20
2 Answers
Reset to default 3u can use
socket.onAny((eventName, args...)=>{
//something
});
https://socket.io/docs/v4/listening-to-events/#socketonanylistener
you can use the wildcard plugin to listen to all events
http://socket.io/docs/faq/ https://github./hden/socketio-wildcard