'How to join room using io instance only?

I have exposed the io object to the response of each request so

const httpServer = createServer(app);
const io = new Server(httpServer, {
  /* options */
});
app.use(function (req, res, next) {
  res.io = io;
  next();
});

Now I want to join all users in a newly created room by POST>>/room rest endpoint but didn't find a way in documentation after researching.

I know that if I have socket instance then it becomes pretty easy like

socket.join(room)

but how can I join all members of the room to socket room?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source