Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用节点 js 和 socket.io,我需要在用户离开应用程序时对其进行管理,这样做的最佳做法是什么?
尝试这个:
io.sockets.on('connection', function (socket) { socket.on('disconnect', function () { console.log(socket.id); }); socket.on('connect', function () { console.log(socket.id); }); });
当用户进入和离开您的应用程序时,您可以获得 socket.id。我希望它有用