如何在socket.io的中间件中获取事件详细信息

我正在尝试logging我的节点服务器上的每个事件的event nameparameter 。 为此我使用了

 io.use(function(socket, next){ // how to get event name out of socket. }); 

现在,我试图获取事件名称和参数时卡住了。 对我来说,它看起来像API开发的共同需求,所以我很肯定,必须有一些方法来图书馆来获取,我试图阅读文档和来源,但我无法得到的东西。

套接字事件需要正确处理,无论如何,如果事件没有处理,将不会有任何回应。

 var io = require('socket.io')(server); var sessionMiddleWare=(session({secret: 'secret key', resave: true, saveUninitialized: true,cookie: { path: '/', httpOnly: true, maxAge: 300000 },rolling: true})); app.use(sessionMiddleWare) io.use(function(socket, next) { sessionMiddleWare(socket.request, socket.request.res, next); }); io.on('connection', function(socket) { // On Socket connection. // inside this you can use different events //event name and parameters can be found in socket variable. console.log(socket.id) // prints the id sent from the client. console.log(socket.data) // prints the data sent from the client. // example event socket.on('subscribe', function(room) { // Event sample. console.log('joining room', room); socket.room=room; socket.join(room); }); }) 

希望这可以帮助。