views:

308

answers:

2

Hi,
I am trying to broadcast a message through the Node.js service socket.io (http://socket.io/) to certain subset of all subscribers.

To be more exact, I would like to use channels that users can subscribe to, in order to efficiently push messages to a couple hundred people at the same time.

I'm not really sure if addEvent('channel_name',x) is the way to go.

I have not found anything in the docs. Any ideas?

Thanks Mat

+1  A: 

It seems you can use Redis publish/subscribe functionality for this. See this link.

Kuroki Kaze
A: 

I'm starting my research into the same problem at the moment. Socket.io looks great, but yes, i think you have to manage the subscriber list yourself. Most example apps out there only use a single subscriber list.

I did come across this... http://faye.jcoglan.com/

It turns your server into a pubsub app. It looks like it manages subscriber lists quite well and it provides a nice hierarchy for channels. However, I can't find an example of it responding to published events within the same app that is running faye?? I'm guessing it's possible. I'll have to have a look at the source. It does seem to give an example of running a separate node app on the server that functions as a client.

The other feature I'm looking for is permissions. I'd want only certain clients to be able to publish to certain channels.

bxjx
As a follow up, I used faye as part of the http://nodeknockout.com/ and it worked out great. On the faye website, there's a nice example of how to you a filter to do authentication, if needed. I also noticed that connect has a middleware plugin to do pubsub. The faye implementation is definitely more complete tho.
bxjx