I'm trying to create a server app in node.js, where multiple clients connect, and then one sends data, and that data gets send to a开发者_如何学JAVAnother specific client. Which client it gets sent to is determined by a 'user id' that all clients will send after they connect.
How can I keep track of clients as they connect? How can I find my specific client? I realize this is a very broad question, but any pointers would be appreciated...
Thanks!
Have a look at some of the existing open source node servers like Socket.IO.
Socket.IO basically assigns each client a unique id. Ids are stored in a hash which is then used as a lookup to identify specific clients - you can create channels as well as broadcast to all connected clients.
精彩评论