title: How to find a user socket in a cluster of socketio processes managed by socketio-redis
body: <p>I'm new to socketio-redis adapter. Originally I had a single socketio process, but now trying a socketio cluster.</p>
  
  <p>When it was a single process, I'd maintain a Map of connected sockets, to find a socket by a userId. When user A emit to a room, if user B was connected but not yet in the room, B's socket was found and joined that room. Then A's socket emit to room.</p>
  
  <p>My question is, how to go about this with socketio-redis?</p>
  
  <p>Below is a simplified plan. Is it possible to add a userId to a socket on connect in one socketio process, then find that socket by userId in a different process?</p>
  
  <pre><code>chatio.on('connect', socket =&gt; {
    // add userId to socket obj
    socket.userId = userId
    . . .
    socket.on("message", async (data, ack) =&gt; {
      const userId  = data.otherUserId
      const roomId  = data.roomId
      const message = data.message
      const clients = await io.of('/').adapter.clients()
  
      // a message came in from user A
      // if user B socket is found, B joins same room
      const otherUserSocket = clients.find(socketId =&gt; {
        const s = io.of('/').adapter.connected[socketId]
        return (s.userId == userId)
      })
  
      if (otherUserSocket) {
        otherUserSocket.join(roomId)
        socket.to(roomId).emit("message", { message })
      }
    }
  })
  </code></pre>
  
  <p>Anyone have experience implementing something like this?</p>