title: better approach for one to one and group chat nodejs Socket.io
body: <p>I am implementing <strong>one to one and group chat</strong> in my application in <strong>NodeJs</strong> using <strong>socket.io</strong> and <strong>angular 4</strong> on client side. I am new to socket.io and angular 4.I want to ask what is better approach for this e.g if user want to send a message to specific user or it want to send a message to group of users.</p>
  
  <p>According to my Rnd should I keep the obj of all connected users and that obj contain the socket id of that user with his user name (email or what ever ) so that if some user want to send message to some one we should need his user name  and we can access his id through his user name .
  Or is there any solution except this ?
  And where should i keep that obj of user and socket id <strong><em>global variable or database</em></strong> ?</p>