通过 io.sockets.sockets 解析时如何获取套接字 ID
How to get the socket id when parsing through io.sockets.sockets
我在 Node.js 服务器上使用 Socket.io。
for (connectedSocket of io.sockets.sockets) {
console.log(`TEST: id = ${connectedSocket.id}`) //Why is this 'undefined'? All I want is the unique identifier of each socket in the server.
}
不确定如何解决这个问题,但它必须非常简单。抱歉,代码格式错误:o
我在 Node.js 服务器上使用 Socket.io。
for (connectedSocket of io.sockets.sockets) {
console.log(`TEST: id = ${connectedSocket.id}`) //Why is this 'undefined'? All I want is the unique identifier of each socket in the server.
}
不确定如何解决这个问题,但它必须非常简单。抱歉,代码格式错误:o