user4305216
user4305216

Reputation:

I'm trying to return socket id?

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

Upvotes: 0

Views: 128

Answers (1)

cmbuckley
cmbuckley

Reputation: 42458

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

Upvotes: 0

Related Questions