【发布时间】:2017-03-02 13:56:26
【问题描述】:
当客户端拥有令牌(由 Laravel jwt 提供)时,我的套接字可以正常工作,但是需要在客户端尚未经过身份验证时与它们一起工作,我想要类似的东西:
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!');
})
如何在验证之前从前端调用“config”(socket.emit('config'))?
感谢您的帮助。对不起我的英语。
【问题讨论】:
-
你好,谁能帮帮我。
标签: node.js sockets socket.io jwt