title: socket io send message to a user in a room
body: <p>I am using nodejs and socketio. I made a private chat app which sends message to selected user.</p>
  
  <p>My current code is : </p>
  
  <pre><code>          chat_room.sockets.socket(user).emit(
                  'chat', 
                  { 
                      message : message,
                      from : sockets[socket.id].username
                  }
              );
  </code></pre>
  
  <p>Now I created rooms and I want to send message to a user of a specific room.</p>
  
  <p>I tried below code but not working</p>
  
  <pre><code>socket.get('room', function(err, room) {
           chat_room.sockets.socket(room)(user).emit(
                  'chat', 
                  { 
                      message : message,
                      from : sockets[socket.id].username
                  }
              );
  
  });
  </code></pre>
  
  <p>Its wrong and it gave me an error : </p>
  
  <blockquote>
    <p>C:\Users\Niraj\Desktop\node\joomla-chat\app.js:62
                  chat_room.sockets.socket(room)(user).emit(
                                                ^ TypeError: object is not a function
        at chat_room.sockets.on.socket.on.socketID (C:\Users\Niraj\Desktop\node\joomla-chat\app.js:62:45)
        at Client.get (C:\Users\Niraj\Desktop\node\joomla-chat\node_modules\socket.io\lib\stores\memory.js:86:3)
        at Socket.get (C:\Users\Niraj\Desktop\node\joomla-chat\node_modules\socket.io\lib\socket.js:258:14)
        at Socket.chat_room.sockets.on.socket.on.socketID (C:\Users\Niraj\Desktop\node\joomla-chat\app.js:48:16)
        at Socket.EventEmitter.emit [as $emit] (events.js:96:17)
        at SocketNamespace.handlePacket (C:\Users\Niraj\Desktop\node\joomla-chat\node_modules\socket.io\lib\namespace.js:335:22)
        at Manager.onClientMessage (C:\Users\Niraj\Desktop\node\joomla-chat\node_modules\socket.io\lib\manager.js:487:38)
        at WebSocket.Transport.onMessage (C:\Users\Niraj\Desktop\node\joomla-chat\node_modules\socket.io\lib\transport.js:387:20)
        at Parser. (C:\Users\Niraj\Desktop\node\joomla-chat\node_modules\socket.io\lib\transports\websocket\hybi-16.js:39:10)
        at Parser.EventEmitter.emit (events.js:96:17)</p>
  </blockquote>
  
  <p>How can I send message to a specific user of a room</p>
  
  <p>-------------------------------EDIT----------------------------
  So if I do : </p>
  
  <pre><code>socket.get('room', function(err, room) {
                chat_room.sockets.socket(user).emit(
                      'chat', 
                      { 
                          message : message,
                          from : sockets[socket.id].username
                      }
                  );
  
          });
  </code></pre>
  
  <p>Then this will fire the message to Mr.X to ABC room</p>
  
  <p>Am I right?</p>