admin管理员组文章数量:1333187
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
本文标签: javascriptSocketon() listen for any eventStack Overflow
版权声明:本文标题:javascript - Socket.on() listen for any event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742267301a2443648.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论