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

4

1 回答 1

0

route函数接收一个SocketRequest对象,因此您需要以下内容:

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

如果需要,您也可以直接访问 socket.io 套接字 ( req.socket),但如果可能,您应该使用上面的 RequestIO 对象。

路由文档

于 2015-05-01T12:08:02.663 回答