Socket.IO授权不刷新

在第一次调用本地主机时,它发送index.html并尝试授权。 授权当然是不被批准的。 在用户完成后,在index.html中填写一个表单“app.post('/ login'…”被执行。

我现在想要的是,login后的授权将被执行一次,客户端与Socket.IO连接。

那可能吗? 或者我必须在客户端login后刷新页面?

app.post('/login', function(req, res) { req.session.status = { test:111 }; res.end(); }); app.get('/', function(req, res){ res.sendfile(__dirname + '/index.html'); }); io.set('authorization', function(req, callback) { console.log("hi"); // check if user is logged, if yes connect with socket.io }); io.sockets.on('connection', function(socket){ });