sensorario
sensorario

Reputation: 21600

How to get NodeJS client id?

Running NodeJs I can see a sort of client 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

I am using socket.io. There is a way to get "hg5ZurBEi8R3Ehf5kuBJ"? A sort of app.session_id.

Upvotes: 1

Views: 4016

Answers (1)

Justas Brazauskas
Justas Brazauskas

Reputation: 321

If you want to get it on server:

var io = require('socket.io').listen(80);

io.sockets.on('connection', function (socket) {
    console.log(socket.id); //client ID
});

Upvotes: 1

Related Questions