javascript - 通过io.sockets.sockets解析时如何获取socket id
问题描述
我在 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
解决方案
推荐阅读
- r - 在 R 中使用 ggplot() 时,函数 scale_size_manual() 不会影响点的大小
- javascript - 如何修复“XML 解析错误:文档元素后的数据无法理解”?
- reactjs - 访问注入孙子组件的数据
- optimization - 如何在要最小化的 Numpy 产品中使用 CVX 变量?
- php - 包括大量的全局/常量变量
- javascript - 在 JQuery 中提交构造的表单时出现错误 403
- android - 无法从 Google Play 获取所有有效订阅
- html - 使分组的项目旋转
- pandas - 为什么相同的矩阵在镶木地板中有不同的尺寸
- python - 如何使用从一个函数到另一个函数的列表值