运行 NodeJs 我可以看到某种客户端 ID:
debug - emitting heartbeat for client hg5ZurBEi8R3Ehf5kuBJ
debug - websocket writing 2::
debug - set heartbeat timeout for client hg5ZurBEi8R3Ehf5kuBJ
debug - got heartbeat packet
debug - cleared heartbeat timeout for client hg5ZurBEi8R3Ehf5kuBJ
debug - set heartbeat interval for client hg5ZurBEi8R3Ehf5kuBJ
我正在使用socket.io。有办法获得“hg5ZurBEi8R3Ehf5kuBJ”吗?一种 app.session_id。
最佳答案
如果你想在服务器上获取它:
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
console.log(socket.id); //client ID
});
关于node.js - 如何获取 NodeJS 客户端 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23148883/