express.io icon indicating copy to clipboard operation
express.io copied to clipboard

I'm trying to return socket id

Open shavidzet opened this issue 10 years ago • 1 comments

Hi, today I tried to use express.io module for the first time and I like it. It's really extended part of socket.io and express.js. But I have a problem. I'm trying to return socket.id in app.io.route event, how can I get client unique id using express.io?

shavidzet avatar May 01 '15 10:05 shavidzet

I tried to parse some data and I can handle unique id, but I don't think that my way is perfect to find unique id. So there is my code to detect socket id:

app.io.route('debug', function(socket) {
    console.log( first(app.io.sockets.sockets) );
});

function first(obj) {
    for (var a in obj) return a;
}

shavidzet avatar May 01 '15 11:05 shavidzet