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 を取得できます。役に立つことを願っています