title: socket.io with redis adapter on express.js: how get all sockets session into room?
body: <p>I want retrive the session of all sockets into room.</p>
  
  <p>I have shared the <code>express-session</code> with the session of socket.io with <code>express-socket.io-session</code>.</p>
  
  <p>My serever: </p>
  
  <pre><code>import * as sharedsession from 'express-socket.io-session';
  import * as session from 'express-session';
  import * as connectRedis from 'connect-redis';
  import * as express from 'express';
  import * as SocketIO from 'socket.io';
  import * as redisSocket from 'socket.io-redis';
  
  // redis optinon
  const redisOption = { port: 'XXX' };
  
  
  // express.js
  const app = express();
  
  // create the redis store for the express session
  const RedisStore = connectRedis(session);
  const expressSession = session({
        name: 'SESSIONID',
        store: new RedisStore(redisOption),
        secret: 'as54f6a65sf4fa',
        resave: false,
        saveUninitialized: false,
        cookie: { secure: true }
  });
  // set the session into express
  app.use(expressSession);
  
  
  // socket.io
  const io = SocketIO(httpServer, {path: '/api/socket.io', origins: '*:*'});
  // se the adapter for socket io
  io.adapter(redisSocket(redisOption));
  // share the express session with socket io
  io.use(sharedsession(expressSession, {autoSave: true}));
  
  // just for test, join all socket into a room 'foo'
  io.on('connection', (client) =&gt; {
      client.join('foo');
  });
  
  
  // start the express server
  app.listen(3000);
  </code></pre>
  
  <p>My attemp to retrive users session into room:</p>
  
  <pre><code>io.in('foo').clients((err, clients) =&gt; {
      for (let i = 0, e = clients.length; i &lt; e; i++) {
          const client = clients[i]; // socket id
          // HOW GET THE SOCKET SESSION?
      }
  });
  </code></pre>
  
  <p>i have also tried</p>
  
  <pre><code>// this works only for the current instance, don't return all sockets into the redis adapter
  const sockets = io.sockets.adapter.rooms['foo'].sockets;
  </code></pre>