如何发出和接收使用socketio-jwt进行身份validation

当客户端有令牌(由Laravel提供的jwt)时,我的套接字工作正常,但是,当客户端尚未validation时需要与客户端一起工作,我想要的东西是:

io.sockets .on('connection', socketioJwt.authorize({ secret: process.env.JWT_SECRET, timeout: 15000 // 15 seconds to send the authentication message })) .on('authenticated', function(socket) { console.log('Authenticated!!'); // This works: socket.on('setDataRegistered', function(datos) { console.log('Registering!'); }); }) // This doesn't works: .on('config', function(socket) { console.log('A client wants to be configured before authenticated!'); }) 

在validation之前,我怎样才能从FrontEnd调用'config'(socket.emit('config'))?

谢谢你的帮助。 对不起我的英文。

我做的是这样的:

 io.on('connection', function (socket) { // Client connected but not authenticated. Client has to emit to 'authenticate' for authentication socket.on('authenticate', function (data, fn) { // Authenticate socket. // define more events }); // still accessible to unauthorised sockets socket.on("other-event", function(data) { }); }); 

我不使用任何中间件进行身份validation。 但那只是我。 我从来没有find它的用途。