0

I'm trying to use express.io module for the first time and I like it. It's really extended part of socket.io and express.js.

I'm trying to return socket.id in app.io.route event. How can I get client unique id using express.io?

app.io.route('debug', function(socket) {
    console.log( socket.id );
});
cmbuckley
  • 40,217
  • 9
  • 77
  • 91

1 Answers1

0

The route function receives a SocketRequest object, so you'll need the following:

app.io.route('debug', function (req) {
    console.log( req.io.id );
});

You can also access the socket.io socket directly (req.socket) if needed, but you should probably use the RequestIO object above if possible.

Routing documentation

cmbuckley
  • 40,217
  • 9
  • 77
  • 91
  • I have already tried req.io.id, but it doesn't work. It shows me undefined message! –  May 01 '15 at 12:19