node.js - Is there a way to append addtiional clients manually to a socket room created by a connected client?
问题描述
I'm having difficulties in finding a solution for a scenario when users are mentioned in the comments section. They receive a notification regardless of their online presence.
module.exports = function (io) {
io.on('connect', function (socket) {
// pre-processing operations to get the users
let users = ['user1', 'user2', 'user3'];
socket.join('room', () => {
// how would I manually join `users` to this room
}
// While broadcasting a message only to those users who were manually joined
socket.to('room').emit('event', {"message" : "You were mentioned in this conversation"})
}
Any suggestions, resources to look into?
解决方案
我不明白你想要达到什么目的。为什么要手动加入它们?
推荐阅读
- amazon-web-services - Cloudformation deploy --parameter-overrides 不接受文件
- firebase - 为什么会从 Firestore 检索数据,尽管给出权限不足的错误?
- php - SQL PHP插入问题
- ios13 - @available(iOS 13.0, *) 中的代码无法在 Xcode 10.2 (IOS Swift) 中编译
- java - 我可以使用 Headless JS 在类中调用函数吗?React-Native 安卓
- php - 使用 PHP 删除 FTP 服务器中包含文件的文件夹
- ruby-on-rails - 在 Heroku 上部署我的 Rails 应用程序时出现错误 H-10
- javascript - 我想当我打开幻灯片菜单汉堡图标消失
- here-api - Javascript API 的 HERE 地图:将地图边界设置为集群边界
- shell - 数据库从 Contao 2.11 迁移到 Magento 2.3 或 Shopware 6.1