【发布时间】:2021-11-06 19:40:18
【问题描述】:
如何在 Socket.io 中存储会话特定信息?
var client={}; //is this static across all sockets (or connected clients) that are connected?
io.on('connection', function(socket){
client.connectiontime=Date.now();
});
//on another io.on('connection') for the same connected client
io.on('connection', function(socket){
store(client.connectiontime);
}
如果客户端变量被认为是静态的,如何仅将客户端变量用于与当前连接的客户端相关的操作?
【问题讨论】:
标签: node.js session variables scope socket.io