Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
官方文档socket.io实例—p2p聊天,中间件auth.js里面
socket.join(room)
放到了nsp.adapter.clients()
里面有问题,导致clients返回到前端无法正常携带当前的socket信息,应该把socket.join(room)
放到nsp.adapter.clients()
外面先执行,亲测如此可以正常返回clients数据。另外clients[id] = query
这个操作和插件本身的操作有冲突,因为socket.join(room)
调用成功后,会自动将socketid放入到clients数组里面。如果想添加多余的信息可以通过其他字段来返回,没必要对这个插件会调用的属性进行操作。