开发者

node.js: Enumerating socket clients

开发者 https://www.devze.com 2023-01-17 19:32 出处:网络
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 t

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消