如何获得NodeJS客户端ID?

运行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 });